User talk:Peter8880

Java basics
This is my first part to my java tutorial for beginners.

To write code you need a programming software. Eclipse is a good one to download.

To start your code you need to make a class. To do this right click file>create>new class. Once you have done this you need to write what you want to compile, to do this you write:

public class HelloWorld { }

HelloWorld refers to the class name. The class name cannot have spaces.

The second thing I am going to cover is a main method. In simple terms this is how the computer interprets your code. The first main method you will learn is quite simple. Keep in mind that java is a case senstive programming language.

public static void main(String[] args) { }

So far you code should look like this:

public class HelloWorld {

public static void main(String[] args) { }     }

Right now our code doesn't do anything. To make it say something you use:

System.out.println("Hello World");

System.out.println("") tells the computer to write whatever is inside the brackets. Hello World is what the computer displays. The semi-colon at the end of the line tells the computer that the line is over and to continue on to the next line of code. System.out.print("") can also be used. The ln tells the code to write it on the next line:

System.out.print("Hello World"); System.out.println("Hello World"); System.out.print("Hello World");

This chunk of code would produce:

Hello WorldHelloWorld

Hello World

So far your code should look like this:

public class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello World");

}     }

This is your first piece of code. It is very basic but when compiled it will print:

Hello World

Peter8880 (talk) 08:28, 1 April 2014 (UTC)

Java Variables
This is the second part of my java tutorial

There are many types of variables in java. An Integer or "int" is used to store small whole numbers. A double is used for small real numbers. 14.976 is an example of a double. A long is used for large Real numbers, 1363642.47384 is an example of a long. Boolean variables can only be two things, true or false.

To use an integer we write:

int variable1;

int tells the code that we are defining an integer. variable1 refers to what we call the variable. You can call it whatever you want but it cannot have spaces.

We can use variables