Declaring constants:final data type constant name [= value] For example: final double PI = 3.1415926;
Ternary operator: conditional? value 1: Value 2 For example: Boolean b=20 < 45? True:false
For Loop statement: for (expression 1; expression 2; expression 3) where expression 1 is the initialization expression, which is responsible for initialization of the variable, expression 2 is a cyclic conditional expression, a Boolean expression, a loop condition is specified, and expression 3 is a post-loop action expression, Responsible for modifying variables, changing cycle conditions such as: for (int i = 2; I <=; i++) {sum = sum + i}
foreach statement: for (element variable x; Traverse object obj) {Java statement referencing X} for example for (int x; {2,3,4}) {System.out.println (x);}
Break statement, is to jump out of the loop body, continue statement, is to jump out of this loop statement
A concatenated string in Java cannot be written separately in two lines, and need to use + as a connection if necessary: System.out.println ("I like" +
"You");
Get string length using: str.length (); For example, String str = "I love You"; int size = Str.length ();
The IndexOf () method returns the location of the first occurrence of the searched character or string, and the LastIndexOf () method returns the position of the search character or the last occurrence of the string. Str.indexof (SUBSTR); Str.lastindexof (substr);
Gets the character of the specified index position:str.charat (int index) str: any string. Index: An integer value that specifies the subscript to return the character.
Java Basic Knowledge points