Hello World! menu

User Tag List

Thread: Hello World!

Results 1 to 9 of 9
  1. #1
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello World!

    Here is a simple script that when run displays "Hello World!" into the commands prompt. More will be explained about it after.

    Code:
    public class Hello
    {
          public static void main(String[] args)
          {
                 System.out.println("Hello World!");
          }
    }
    "public static Hello" is defining the class to be:
    public (Can be accessed by other classes)
    static (can be access inside this file)
    and to be named "Hello" (NOTE!: your file must be named the same as the class that contains the main method header, which in this case would be the Hello class)

    "public static void main(String[] args)" is the main method header, any file that will be ran will need this method.
    public (can be accessed by other classes or methods)
    static (can be accessed by the rest of this class or other methods in this class)
    void (the method's return type)


    I must go for now but soon I will post a guide on compiling and running a java class file in a windows OS. :wave:
    Last edited by Pragma; 03-19-2008 at 08:58 PM.


    Hello World!
  2. #2
    Lahtaaja's Avatar Member
    Reputation
    8
    Join Date
    Jan 2008
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is legend
    The first thing I learned about programming [if not counting endless hours sitting front of WC3 WE].
    +Rep for you xD

  3. #3
    cubed's Avatar Member
    Reputation
    27
    Join Date
    Feb 2008
    Posts
    82
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by insanesk8123 View Post
    Here is a simple script that when run displays "Hello World!" into the commands prompt. More will be explained about it after.

    Code:
    public static Hello
    {
          public static void main(String[] args)
          {
                 System.out.println("Hello World!");
          }
    }
    "public static Hello" is defining the class to be:
    public (Can be accessed by other classes)
    static (can be access inside this file)
    and to be named "Hello" (NOTE!: your file must be named the same as the class that contains the main method header, which in this case would be the Hello class)

    "public static void main(String[] args)" is the main method header, any file that will be ran will need this method.
    public (can be accessed by other classes or methods)
    static (can be accessed by the rest of this class or other methods in this class)
    void (the method's return type)


    I must go for now but soon I will post a guide on compiling and running a java class file in a windows OS. :wave:
    Actually, you're wrong about half of the stuff in this post.

    First off, "public static Hello" will not compile. You can't have a static modifier on a class, only public, abstract, and final.

    Secondly, you said "static (can be accessed by the rest of this class or other methods in this class)" which is entirely wrong. The static modifier on a method in a class means that it can be accessed by anything, take for instance the Integer.parseInt(int x) method, which is static.

    Anyway, you definitely don't deserve rep for this.

  4. #4
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I meant to put public class Hello but everything else I said was correct soo would you kindly F*** off. =)

    You don't even know what your talking about 'public' is what makes it accessible by everything.
    Last edited by Pragma; 03-19-2008 at 09:05 PM.


  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Public simply makes the class accessible to the current assembly. "Accessible by everything" is a bad way of saying it.

    ""public static void main(String[] args)" is the main method header, any file that will be ran will need this method." While somewhat correct, again, bad wording. The "main" function is the entry point for the program. Anything you want to be run on startup, should be added here. (Usually this turns into a call to another method, which handles most of the startup tasks as the main method is usually hidden where it can't easily be tinkered with.) The compiler implicitly looks for the first occurrence of the "main" method to begin the application. (Keep in mind, you cannot have 2 of the same method names. Or member names for that matter.)

    One more thing to keep in mind, "main" is not the same as "Main".

    "Void" is not a return type per-se. Void is declaring that this method has NO return type. And should be executed without expecting anything in return.

  6. #6
    jdismeuc's Avatar Contributor
    Reputation
    125
    Join Date
    May 2007
    Posts
    542
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could use html... lol

  7. #7
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jdismeuc View Post
    Or you could use html... lol
    what that doesnt even make sense, you have to clue what were doing.


  8. #8
    jdismeuc's Avatar Contributor
    Reputation
    125
    Join Date
    May 2007
    Posts
    542
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh wow, sorry. I did not realize that this was all in Command Prompt. Maybe I should try reading? hmmm....

  9. #9
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no its cool, didnt mean to get mad like that XD


Similar Threads

  1. "Hello World" to making bots & hacks
    By Hi on helium in forum Programming
    Replies: 5
    Last Post: 11-14-2009, 07:33 PM
  2. Hello World, in C++.
    By MaiN in forum Programming
    Replies: 40
    Last Post: 09-05-2008, 10:25 AM
  3. Hello World, in DarkBASIC
    By ReidE96 in forum Programming
    Replies: 0
    Last Post: 03-14-2008, 06:26 PM
  4. Hello world !
    By tttommeke in forum Programming
    Replies: 4
    Last Post: 03-09-2008, 10:53 AM
All times are GMT -5. The time now is 11:18 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search