Multi-Dimensional Arrays
int [][]numbers = {{1,2,3},{4,5,6}} ;
//each row is array itself,because it's a list of items
System.out.println(Arrays.deepToString(numbers));
result
[[1, 2, 3], [4, 5, 6]]
Constants
final float PI = 3.14F;
//use all capitalized letter to name const
Arithmetic Experssions
int x = 1;
int y = x++;
System.out.println(x);
System.out.println(y);
result
2
1
Casting
//Q:how many bytes do we have in a short variable?
/*A:we have 2 bytes in a short variable.*/
//Q:how many bytes do we have in a integer variable?
/*A:we have 4 bytes in a short variable.*/
/*so any value we stored in a short variable
can also be stored in a integer varible.
*/
//1.Implicit casting
//there is no chance for data to lose
//byte => short => int => long => float => double
//2.Explicit casting
Integer.parseInt(String s);
Short.parseShort(String s);
Float.parseFloat(String s);
//An example
String x = "1";
int y = Integer.parseInt(x) + 2;
System.out.println(y);
result
3
//why this matters?
/*almost always we get values as Strings*/
//Another example
String x = "1.1";
double y = Double.parseDouble(x) + 2;
System.out.println(y);
result
3.1