-
Download a development environment such as "Eclipse" or "Netbeans".
-
Create a new class selecting new/class.
-
A class remodels a real world projects or code into code.
-
Start writing the code importing Java libraries
##java default libraries.
import java util.Scanner;
import java.util.*;
public class "classname"{
- methods declaration
private "datatype(float,int etc)" "method name";
-
methods are always private, except the main method.
-
Once methods are declarated, you must generate constructors
-
right click/source/generate constructor using fields
-
The contstructor is now generated.
public "classname"{
- Now you can carry out different tasks, for example printing on the screen a sum of numbers.
}
- Now you need to create a main method, where the code will be executed.
public static void main(String[] args){
- "static" means that this method is shared with every object with the name of this class.
- Create now a new object.
"classname" "newname" = new "classname"();
}
}