[Java] Hello World!

Discussion in 'Archives' started by Redemption, Feb 15, 2007.

[Java] Hello World!
  1. Unread #1 - Feb 15, 2007 at 8:12 PM
  2. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    [Java] Hello World!

    This guide teaches you how to make a program that displays "Hello World!" in the applet without using objectdraw. If you're a beginner, objectdraw is easier. If you want to see the basics of Java. Look at my objectdraw guides. If you want the real thing, this is a good place to start.

    First, you'll need a text editor. You can use notepad, but it will be much less neat and harder to read. I recommend using TextPad, because it automatically formats the code for you. It makes it a lot easier to understand long code.

    TextPad can be found here.

    Let's start out with the full code.

    Code:
    public class HelloWorld {
     
       public static void main(String[] args) {
          System.out.println("Hello World!");
          //prints Hello World! on the canvas
       }
          
    } 
    Ignore this next paragraph if you didn't read my objectdraw guides-
    As you can see, this is only a tiny bit of code. If you used my objectdraw guides, there was a lot more there. This is because objectdraw shortens it out into easily memorized code. Yeah, it's kinda gay trying to go from objectdraw to regular java without includes, but you'll get used to it.

    If you haven't read my objectdraw guides can start reading here. Those who have may continue-

    So, let's start at the beginning.

    Code:
    public class HelloWorld {
    This part of the code tells that you're starting up a new class (program, basically) to be used throughout the whole program (public) called HelloWorld. After this part of the code, you'll see an open bracket. This means that the code in between that and the end bracket have to do with the class. Easy enough?

    **Whatever you name your class, you *must* name your java file! For example, in this program, you must save your file as HelloWorld.java. If you don't, you will get an error that will piss you off. In fact, you'll probably never figure it out.

    Okay, let's move on.

    Code:
       public static void main(String[] args) {
    Here, you are declaring a void, which basically means a part of the program that is usable within the applet. The stuff around "void" needs a bit of explanation. Let's break it down.

    public- means it will be used throughout the whole program and can be used more than once. This should begin almost every void you declare.

    static- means the void can *never* change. You don't need to add static, I just wanted to teach you what it means.

    main- self explanatory. Let me know if you don't understand it fully.

    (String[] args)- It tells java there is a string of characters that will be used. A string is letters or numbers to be displayed on the applet. Our string in this program is "Hello World!".

    { - Shows it where the code is. Between this and the end bracket is where the program for this specific void goes.

    Let's move on again.

    Code:
    System.out.println("Hello World!");
    This tells the system to print into the canvas the string "Hello World!". I think it's easy enough to understand. Afterwards, though, you'll see a semicolon. This tells it that that line is done. DO NOT PUT A BRACKET!

    Let's move on... again...

    Code:
    //prints Hello World! on the canvas
    This is a comment, which is basically a statement java ignores. This will have no effect on your program, it will just make it easier for the coder to remember what he or she was doing.

    Let's wrap it up...

    Code:
    }
    }
    The first bracket tells java that the void code is finished. The second bracket ends the class. If you were to have another void, it would go in between these two brackets, saying that the first void was over, but the class is still going. Then, at the end, there would be two brackets. The first one closing the second void, the second closing the class.

    So, there you go. If you had any trouble understanding this, gimme a PM. I'll get back to you when I can.
     
  3. Unread #2 - Feb 16, 2007 at 12:53 AM
  4. TheDeathDealer
    Referrals:
    0

    TheDeathDealer Guest

    [Java] Hello World!

    Kool tut, an add-on for it could be:

    javascript:alert('WARNING: Antivirus software has detected you are running Microsoft Windows XP, please switch to a REAL OS such as Linux to continue');

    Or type "javascript:alert('messageinhere');" I made my teacehr freak out by having it say that Symantec AntiVirus was wiping the network hardrives
     
  5. Unread #3 - Feb 16, 2007 at 9:36 AM
  6. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    [Java] Hello World!

    That's javascript, not java. They're totally different languages. Besides, I already wrote a guide on how to do that. =P
     
  7. Unread #4 - Feb 16, 2007 at 10:47 AM
  8. WoW Sucks
    Joined:
    Jan 21, 2007
    Posts:
    3,708
    Referrals:
    3
    Sythe Gold:
    0

    WoW Sucks Global Moderator
    Banned

    [Java] Hello World!

  9. Unread #5 - Feb 16, 2007 at 2:59 PM
  10. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    [Java] Hello World!

    It's extremely similar to the code because that's the only simple way to make the canvas say "Hello World!"... The guide is totally different. That's the basic way to say it. It's not like java code varies from person to person. There are limited commands that can be used for a noob.

    I didn't even see thatguide , so don't accuse me. Ask anyone who codes java how to make the canvas say "Hello World!" without objectdraw in a simple way, and they'll give you the exact same code.

    I'm not a retard. I wouldn't copy a guide right out of the sythe archive. Besides, I have totally different instructions.

    Edit: and notice how it explains how to make the command prompt say "Hello World!" as well as the canvas. I wrote nothing about the command prompt.

    And on top of that, that guide doesn't even tell you how to use comments.

    So before you accuse someone, come up with a real accusation and find your place. You obviously know about shit's worth in java. You've really just lost my respect in you. Good job. Learn to read.

    Edit again: And don't say anything about Textpad. Most programmers use it, and it's what I was introduced to when I learned java in school.
     
  11. Unread #6 - Feb 16, 2007 at 6:06 PM
  12. WoW Sucks
    Joined:
    Jan 21, 2007
    Posts:
    3,708
    Referrals:
    3
    Sythe Gold:
    0

    WoW Sucks Global Moderator
    Banned

    [Java] Hello World!

    I wasn't accusing you of ripping, i was wondering why you chose to make it say "Hello world". The link i posted also says "Hello world"...
     
  13. Unread #7 - Feb 16, 2007 at 10:55 PM
  14. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    [Java] Hello World!

    Because that's the universal beginner lesson for every programming language.
     
  15. Unread #8 - Mar 8, 2007 at 4:48 AM
  16. -------owned-------
    Joined:
    Jan 27, 2007
    Posts:
    1,225
    Referrals:
    0
    Sythe Gold:
    0

    -------owned------- Guru
    Banned

    [Java] Hello World!

    Nice, I'm a beginner of Java :)
     
  17. Unread #9 - Mar 8, 2007 at 7:20 PM
  18. Redemption
    Joined:
    Jan 22, 2007
    Posts:
    429
    Referrals:
    0
    Sythe Gold:
    0

    Redemption Forum Addict
    Banned

    [Java] Hello World!

    I wish I were amazing... I'm decent but not amazing.
     
< Inactivity | Hax4You for user ed? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site