Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: What is that at the end of a method

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question What is that at the end of a method

    Ok so i have been independent here for little while and that seems to be my only option and the thing is reading something doesn't usually do it for me i dont take in information from reading, especially with a lot of terminology involved. Which is an awful problem
    for trying to learn programming.
    Anyways ive been jumping around and starting to grasp some things pretty well (i may not be actually i just think i am).

    Question is, what is the stuff that is red at the end of the method(if thats even called a method i hope im not that confused with the vocab).

    static void main(String[] args)

    If you must use terminology to explain something try to keep it light but dont keep it all out i will need to understand all the terminology at some point as well. but DO tell me what this red is called in terminology so i will have a more direct way of finding info on it.

    I want to know what this is as in any method not particularly this one, i remember reading something about this one taking arguments from the command line interface? anyways what is that red stuff and how important is it to know and understand.

    sorry about the jumbled question im in a hurry sort of, and thanks for the help.


  2. #2
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: What is that at the end of a method

    Okay that is the parameters of a method.


    accessControl returnType name(Parameters)

    That is the basic of a method. To break it down
    • Access Control: Can other classes access this method? More Info
    • Return Type: What type will this method return? More Info
    • Parameters: What information is passed to the method called More Info


    Other Recommended Reading
    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Java Programmer's SourceBook : Thinking in Java

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is that at the end of a method

    Ok so its Parameters that get me.

    Ok so i understand i think?
    So what your doing is passing information to the method, and when it is passed from whatever variable it may be or object the values are sort of copied not actually directly changed by the method that use them? is that all correct?
    I guess what im looking for is an example that can be explained why the parameters are put there.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: What is that at the end of a method

    Did you read the tutorial posted by Tjstretch? You should read that entire section, including this part: Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: What is that at the end of a method

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is that at the end of a method

    Ok so why would you not just create the variable in the method, why use parameters?

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: What is that at the end of a method

    Because that doesn't make sense. For example, System.out.println(String) is a method takes a String parameter, right? How would that method know what to print without that parameter? Methods are meant to be reusable as opposed to simply doing the same thing every time they're called. How would you do that without parameters?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is that at the end of a method

    oh ok atleast i might understand one part of this whole picture, i apologize for being such a slow learner.

    so if i had a method and all i wanted the method to do was take some Item objects and find if there slots are available by changing it true or false, it may look something like this.


    public boolean Availability(Item item1, Item item2, Item item3){
    //some code that determines if an item is there in that item slot
    if (there be an item there){
    return false;
    }
    else{
    return true;
    }
    }

  9. #9
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: What is that at the end of a method

    Quote Originally Posted by poetzmij View Post
    oh ok atleast i might understand one part of this whole picture, i apologize for being such a slow learner.

    so if i had a method and all i wanted the method to do was take some Item objects and find if there slots are available by changing it true or false, it may look something like this.


    public boolean Availability(Item item1, Item item2, Item item3){
    //some code that determines if an item is there in that item slot
    if (there be an item there){
    return false;
    }
    else{
    return true;
    }
    }
    Dpending upon, if you want your method to return false in case, it finds the Item, the pseudocode is FINE.

Similar Threads

  1. Replies: 3
    Last Post: October 31st, 2011, 12:42 AM
  2. How do I call a method from the main method?
    By JavaStudent1988 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 19th, 2011, 08:37 PM
  3. Can you pass parameters from one method into another method?
    By u-will-neva-no in forum Java Theory & Questions
    Replies: 2
    Last Post: April 14th, 2011, 07:46 AM
  4. Help with toString method and an addObject method?
    By Camisado in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 12th, 2011, 07:00 AM
  5. Can i call init() method in destroy method.?
    By muralidhar in forum Java Servlet
    Replies: 1
    Last Post: October 22nd, 2010, 11:18 AM