Hump nomenclature: class names are nouns that start with a capital letter, capitalize the first letter of each word.
java main method does not return value
Use the java doc
Floating-point value does not apply to unacceptable financial calculations rounding error in using bigdecemial
Escape character codes explained before: for example, "\ u0022 + \ u0022" is not composed of a plus sign string surrounded by quotation marks (U + 0022). In fact, \ u0022 is converted before parsing ", which will get is an empty string.
For strictfp method key mark must be strictly point calculations to generate reproducible results.
public class jj { public static void main(String[] args) { int a = 10%-3; int b = -10%3; int c = -10%-3; System.out.println(a+","+b+","+c); }}
Take the remainder were close to zero.
floorMod into a downward modulo.
Casts are cut off, Math.round to rounding.
Determined using short time.
String all = String.join( " / ", "S", "M", "L", "XL" ); // all is the string "S / H / L / XL"
null value detecting
Console cons = System.console(); String username = cons.readLine("User name: "); char [] passwd = cons.readPassword("Password:");
For security reasons, the password is stored in the return of the one-dimensional array of characters instead of a string. After the cryptographic processing, it should be immediately covered with a padding value array element (array process will be described in Section 3.10).
Formatted output:
foreach statement format:
for (type element type variable element value: traverse the object obj) {
Java statement quoted the x;
}
Using this syntax can re-initialize an array without creating a new variable. For example:
small Primes = new int[] { 17, 19, 23,29, 31, 37 }
This is a short form of the following statement:int[] anonymous = { 17, 19, 23, 29, 31, 37 }; smallPrimes = anonymous
static int binarySearch (type [] a , int start, int end, type v)
using a binary search algorithm to find the value v. If found, the corresponding index value is returned; otherwise, returns a negative value r. -r-1 is ordered to maintain a v should be inserted.In all methods in a class in the class instance variables can not be named in the same domain name.
Getxxx return value accessor methods must be immutable objects such as String, and if the object is returned inevitably mutable objects, e.g. Date, clone the object is returned.
class Emloyee{ public Date getHireDay(){ return (Date)hireDay.clone(); } }
If there are front final modification example domain, the construction of this object must be initialized when such domain.
NumberFormat currencyFormatter = NumberFormat.getCurrencylnstance(); NumberFormat percentFormatter = NumberFormat.getPercentInstance(); double x = 0.1; System.out.println(currencyFormatter.format(x)); // prints $0.10 System.out.println(percentFomatter.format(x)); // prints 10%
A similar approach is referred to as a factory method.
If a class is provided in at least one constructor, but did not provide a no-argument constructor, so if no argument when constructing the object is considered illegal.
End does not make sense, do not Transcription, and directly draw focus. . .