How to learn Java

Posts 15 of 5 · Page 1 of 1
How to learn Java
 
DISCLAIMER

THIS TUTORIAL WILL NOT TEACH YOU EVERYTHING IN JAVA. I WOULD RECOMMEND (IF YOU REALLY WANT TO LEARN) BUY A BOOK OR WATCH THE NEW BOSTON'S TUTORIALS, OR ORACLE'S. THIS TUTORIAL IS NOT FINISHED.

Okay you want to learn Java huh?
Trust me it's not that hard.
Lesson one: Getting out of the water.
Section A: Hello MPGH:
Let's start, I'll give you some code and then I'll explain it:
Code:
public class Main {
    public static void main(String[] Args) {
        System.out.print("Hello MPGH!");
    }
}

This will display Hello MPGH!

How it works:
Code:
public
Public says: "HEY ANYBODY CAN ACCESS ME! (or/if not they have to import me.)"
Code:
class
Classes are the blueprint for code.

Code:
Main
Main is what we named the class so essentially you can do this:
Code:
public class <Your Class Name Here>
Whats the public static void main mumbo-jumbo?
Code:
public static void main(String []Args)
That's like java being the guy who verifies your passport at the airport.
He's checking it if it's counterfeit. And if your program doesn't have this then it won't run, like the airport guy won't let you pass.

What's the System.out thing?
Code:
System.out.print("Hello MPGH!");
That's printing letters on to the screen. In this case it's "Hello MPGH!".

You can change the text for what you want it to output. Make sure your text goes inside the " ".

Q: What are the curly braces for?
A: They determine sections of code. (Not the best explanation.
SECTION B: Variables:
In case you wondering this is how you do comments in java:
Code:
//This is a comment.
/* This is a comment */
This is how i'll be explaining, with comments so look at the code.
Code:
public class Main { /* Public(I'm accessible to anyone!) class (Blueprint)  Main(Name of Class) */
    public static void main(String[] Args) /* That guy at the airport. */ {
        String MPGH = "Hello MPGH!"; /* Declaring a Variable that is a String. MPGH is Equal to the String (Or String of words) Hello MPGH! */
        System.out.print(MPGH);  /* Printing out the Variable MPGH which has the value "Hello MPGH!"  */
    }
    /* Ending the void */
}
/* Ending the class */
There are some more "String type thingies."
Code:
int /* is an integer */ 
Code:
public class Main { /* Public(I'm accessible to anyone!) class (Blueprint)  Main(Name of Class) */
    public static void main(String[] Args) /* That guy at the airport. */ {
        String MPGH = "MPGH is ";/* Declaring a Variable that is a String. MPGH is Equal to the String (Or String of words) MPGH is */
        int year = 12;
        System.out.print(MPGH + year);  /* Printing out the Variable MPGH and adding the Variable year which is an int. This will result in MPGH is 12. */
    }
    /* Ending the void */
}
/* Ending the class */
Nice.
A classic Hello world, but instead Hello MPGH.
The only thing is you barely even hit the surface of java.
Quote Originally Posted by ProjectXOwner View Post
What program to use?
Eclipse Standard
Quote Originally Posted by argyros View Post
Eclipse Standard
Thank you very much i have a private server and i want to develop my skills and make my server cool
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?