- byte
- short
- int
- long
- %d
- float
- double
- %f
- char
- %c
- boolean
- %b
%s is used for String, but its not a primitive datatype.
System.out.printf()
can be used or store in a string directly using String.format(<string>, <variables>)
.
- Eg. Date, Point
- long
123L
- float
1.3F
(double)10
is explicit casting
int[] arr = new int[5]
int[][] arr = new int[2][3]
- use
final
keyword - uppercase convention
()
/, *
+, -
Integer.parseInt()
Float.parseFloat()
- etc.
Scanner scanner = new Scanner(System.in);
// now you can use scanner.next<datatype>
byte age = scanner.nextByte();
// single token
String firstName = scanner.next();
// with whitespaces
String fullName = scanner.nextLine();
// ...
scanner.close();
- for
- while
- do-while
- for-each