Java
Jump to navigation
Jump to search
20220531
Fist notes on java programming.
public class HelloWorld {
public static void main(String args[] ) {
String text = "hello world";
System.out.println( text );
}
}
If a class implements an interface all methods in that interface must be defined in the class
Variables
- int var1 = 0
- Variables must be declared and initialized
- private int var1;
- Private variables in classes can only be accessed from within the class (same for methods).
Methods
- Every program must have a main method, that is executed when the program starts
- A 'void' method is a method with no return value, else the return value type must be specified
- Private methods in classes can only be accessed from within the class (same for variables).