Results 1 to 11 of 11
  1. #1
    bukake is offline Member
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    0

    Cool Can a method take itself as parameter?

    Can a method take itself as parameter? Recursive method maybe. And whats the new feature in 1.7 release. Someone told me it was something with calling multiple methods, or maybe taking other methods as parameters. Any info on thisone?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I don't know about passing a method as a parameter to a method itself. Maybe you are talking about recursive method. Can you specifically say what exactly you want to do.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default

    A method doesn't have a type, so I don't see how it could be passed as a parameter to another method. How would you define the called method?

    public void calledMethod(PassedMethod pm) {...

    Then what would its parameters be if you call it?
    pm(<someargs???>);

    Its always possible for new syntax to be added to java. This could be defined in future versions of java.

  4. #4
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    Maybe he means:
    Java Code:
    String length = getStringLength(textField.getText());
    where getStringLength is a non-existing method...
    I die a little on the inside...
    Every time I get shot.

  5. #5
    bukake is offline Member
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    0

    Default

    I guess it is the closures that are proposed to be added in the new versions. My teacher said something about adding very powerful stuff in the new version, but it was something to do with the methods passing as arguments in other methods, I'm not really sure. Or maybe multiple inheritance. Its all mashup now in my head with this Java thing. Tnx for the replies :)

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I don't think new version has this kind of feature at all. I search on the Suns' official web site, but didn't found such thing.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I have heard of closures as a possible addition to the next version.

    As for method parameters, these can be implemented in a sideways fashion using interfaces. We do this with Runnables all the time.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    then why not have a read (interesting stuff!): Closures for the Java Programming Language

  10. #10
    bukake is offline Member
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    0

    Default

    Nice link. I need to get my routine with some more basic stuff until i get there. Imo you need to decide when it's time to stop learning, i think many would disagree on that. But with all these new features, aspect programming etc its just another way to get things done, with less code maybe.

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Nice link. I need to get my routine with some more basic stuff until i get there.
    Don't rush. Closures are not part of Java yet, so there's nothing to "get to" just yet!
    Imo you need to decide when it's time to stop learning, i think many would disagree on that.
    I don't disagree at all. I think you should stop learning when you're dead. I'm in no rush.

Similar Threads

  1. Retrieving a parameter through URL.
    By hisouka in forum Java Servlet
    Replies: 1
    Last Post: 09-06-2008, 01:45 PM
  2. how to read a url parameter to query a database
    By kwesiaryee in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-01-2008, 03:38 PM
  3. Passing short value as parameter
    By javanewbie83 in forum New To Java
    Replies: 16
    Last Post: 07-16-2008, 06:27 AM
  4. Input parameter of Main method
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 07-12-2008, 07:24 PM
  5. arugment/parameter
    By ravian in forum New To Java
    Replies: 5
    Last Post: 01-04-2008, 10:43 AM

Posting Permissions

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