Results 1 to 9 of 9
Like Tree4Likes
  • 1 Post By stchman
  • 2 Post By Willriker
  • 1 Post By Junky

Thread: Quite Irked :\

  1. #1
    Hyperion is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default Few Questions;

    So, lately I have taken an interest in Java, and have attempted to learn it, but I find myself unable to actually learn anything. These online tutorials slap a code in my face, cool, I have no idea what it means, why you have to type certain things. What would happen if I were to substitute it with something? Are there certain words I can use? Like.. I'm utterly confused.

    This is what I have learned, I'll bold the things I need help with:

    public class Hello World {
    public static void main (String[] args) {
    System.out.println ("Hello World!");
    }//End of main
    }//End of class

    What exactly does all of this do? Yes, I know I have to run it via Command Prompt, but I want to know why I have to type certain things.

    Are there things I can substitute for static, void, main, args? What is all of this doing?!?! I'm quite annoyed by this, because if I don't know what they do, I will be unable to write my own program.

    Please help :\
    Last edited by Hyperion; 08-22-2011 at 11:42 PM.

  2. #2
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Location
    Saint Louis, Missouri
    Posts
    97
    Rep Power
    0

    Default

    Quote Originally Posted by Hyperion View Post
    So, lately I have taken an interest in Java, and have attempted to learn it, but I find myself unable to actually learn anything. These online tutorials slap a code in my face, cool, I have no idea what it means, why you have to type certain things. What would happen if I were to substitute it with something? Are there certain words I can use? Like.. I'm utterly confused.

    This is what I have learned, I'll bold the things I need help with:

    public class Hello World {
    public static void main (String[] args) {
    System.out.println ("Hello World!");
    }//End of main
    }//End of class

    What exactly does all of this do? Yes, I know I have to run it via Command Prompt, but I want to know why I have to type certain things.

    Are there things I can substitute for static, void, main, args? What is all of this doing?!?! I'm quite annoyed by this, because if I don't know what they do, I will be unable to write my own program.

    Please help :\
    Java applications are always going to be class method structured. The main method must always be static. Also the name of the file MUST be the same name as the class.

    i.e. class name is DataRecovery, source for DataRecovery is DataRecovery.java

    It is customary that the class name have no spaces.

    As far as the String[] args, the compiler allocates an array of Strings based on what you type at the command line.

    For example:

    Java Code:
    javac -cp . HelloWorld.java
    This will result in a Foo.class being created.

    To run your new HelloWorld class do the following:

    Java Code:
    java -cp . HelloWorld
    If I typed:

    Java Code:
    java -cp . HelloWorld Hello Goodbye Yes No
    Then the String[] args would be dimensioned to 4 elements and the array would be as follows:
    args[ 0 ] = "Hello"
    args[ 1 ] = "Goodbye"
    args[ 2 ] = "Yes"
    args[ 3 ] = "No"

    I hope this helps.
    Fubarable likes this.
    If you aren't programming in Java, well that's just too bad.
    I'd rather be using Ubuntu.

  3. #3
    Hyperion is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by stchman View Post
    Java applications are always going to be class method structured. The main method must always be static. Also the name of the file MUST be the same name as the class.

    i.e. class name is DataRecovery, source for DataRecovery is DataRecovery.java

    It is customary that the class name have no spaces.

    As far as the String[] args, the compiler allocates an array of Strings based on what you type at the command line.

    For example:

    Java Code:
    javac -cp . HelloWorld.java
    This will result in a Foo.class being created.

    To run your new HelloWorld class do the following:

    Java Code:
    java -cp . HelloWorld
    If I typed:

    Java Code:
    java -cp . HelloWorld Hello Goodbye Yes No
    Then the String[] args would be dimensioned to 4 elements and the array would be as follows:
    args[ 0 ] = "Hello"
    args[ 1 ] = "Goodbye"
    args[ 2 ] = "Yes"
    args[ 3 ] = "No"

    I hope this helps.
    Helps a tad bit. Could you refer me to something that would help me understand what "String", "args", etc are doing? Like, is there an index of sorts I can refer to?

  4. #4
    Willriker is offline Member
    Join Date
    Aug 2011
    Posts
    47
    Rep Power
    0

    Default

    The best way i can help you is to try to get you to google each of those terms individually. google java public, java main, java void and so on. Java is very popular, so there is a ton of information out there.

  5. #5
    Willriker is offline Member
    Join Date
    Aug 2011
    Posts
    47
    Rep Power
    0

    Default

    google the 'really big index' tons of info there.
    Fubarable and sunde887 like this.

  6. #6
    Hyperion is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Willriker View Post
    google the 'really big index' tons of info there.
    Thanks! HUGE amounts of information there, I'm amazed at the amount of information there. Thank you, hopefully I will be able to retain most of the information ^^

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    Quote Originally Posted by Hyperion View Post
    hopefully I will be able to retain most of the information
    The beauty of the internet is you don't have to.
    DarrylBurke likes this.

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

    Default

    Quote Originally Posted by Hyperion View Post
    Thanks! HUGE amounts of information there, I'm amazed at the amount of information there. Thank you, hopefully I will be able to retain most of the information ^^
    If you do, you'll be better than 90% of us. If you're like the rest of us, you'll retain that which you use and re-use.

    Best of luck, and have fun coding!

  9. #9
    Hyperion is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    If you do, you'll be better than 90% of us. If you're like the rest of us, you'll retain that which you use and re-use.

    Best of luck, and have fun coding!
    Yeah, I'm finding myself getting a bit confused with some things, but the index is a useful tool in aiding me. :D

Posting Permissions

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