Results 1 to 4 of 4
  1. #1
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default shared sub visual basic/ java replacement?

    one of my first languages I learned was visual basic. you had to ability to create shared subs. if you create a shared sub or function and then imported the class containing the sub or function in another class you could call the function like this: sub()

    I am bad at explaining so let me give an example:

    class utils
    shared sub println(byval text)
    ...
    end sub

    and when you implemented that class
    you could type println() instead of utils.println()

    now my vb is very rusty and the example is not correct but I think you get what I mean

    is this also available in java?
    it would come in really handy for what I am doing

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by dinosoep View Post
    one of my first languages I learned was visual basic. you had to ability to create shared subs. if you create a shared sub or function and then imported the class containing the sub or function in another class you could call the function like this: sub()

    I am bad at explaining so let me give an example:

    class utils
    shared sub println(byval text)
    ...
    end sub

    and when you implemented that class
    you could type println() instead of utils.println()

    now my vb is very rusty and the example is not correct but I think you get what I mean

    is this also available in java?
    it would come in really handy for what I am doing
    Read what the enhanced import statement (since Java 1.5) can do for you.

    kind regards,

    Jos

  3. #3
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    I couldn't find something about enchanced import statements but while searching after it I stumbled upon static import statements, they do what I want.
    So in the end, your answer solved my problem :)

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by dinosoep View Post
    I couldn't find something about enchanced import statements but while searching after it I stumbled upon static import statements, they do what I want.
    So in the end, your answer solved my problem :)
    Yep, you're right, it's a 'static import' and an 'enhanced for-loop'; I never use those static imports and didn't really know what it was called anymore but I remembered they do what you wanted ;-)

    kind regards,

    Jos

Similar Threads

  1. String replacement...
    By diskhub in forum New To Java
    Replies: 6
    Last Post: 05-19-2010, 04:20 AM
  2. Replies: 0
    Last Post: 12-08-2008, 02:30 PM
  3. Looking for JGroups replacement
    By asynchrony in forum Networking
    Replies: 4
    Last Post: 10-17-2008, 10:54 PM
  4. Eclipse launching Visual Basic
    By FireFly in forum Eclipse
    Replies: 1
    Last Post: 10-03-2008, 08:22 PM
  5. Shared Scientific Toolbox in Java 1.01
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 05-08-2008, 06:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •