Java: Difference between revisions
Jump to navigation
Jump to search
Created page with "20220531 Fist notes on java progamming. <syntaxhighlight lang=java> public class HelloWorld { public static void main(String args[] ) { String text = "hello world"; Sys..." |
No edit summary |
||
| Line 1: | Line 1: | ||
20220531 | 20220531 | ||
Fist notes on java | Fist notes on java programming. | ||
<syntaxhighlight lang=java> | <syntaxhighlight lang=java> | ||
| Line 15: | Line 15: | ||
=Variables= | =Variables= | ||
;int var1 = 0 | ;int var1 = 0 | ||
:Variables must be declared and | :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). | |||
Revision as of 09:04, 17 June 2022
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).