l Utility Classes
l Class, Method, Constructor, Boolean, ... is Object.
l System Properties (system parameters)
use
Remove or set system parameters
Example
Java -deigh = 8 TEST
Println ("Java.Version"); //1.4.2
System.SetProperty ("Two", 2);
Integer Wi = Integer.Getinteger ("Two");
Println (wi.tostring); // 2
System.SetProperty ("Love", "True");
Boolean B = Boolean.getBoolean ("Love"); // true
Ingeger Wi2 = Integer.getinteger ("EIGH", 999);
Println (wi2.tostring ()); // If there is a "8" if there is a "8" in the top, otherwise "999"
Methods
Integer
Static Integer GetInteger (String Key)
Static Integer GetInteger (String Key, Int Val)
Static Integer GetInteger (String Key, INGETER VAL)
Long
Static Long getlong (String Key)
Static Long Getlong (String Key, Int Val)
Static Long Getlong (String Key, Long Val)
Boolean
Static Boolean getBoolean (String Key)
note
The parameter "key" refers to ProPery Name, "Val" is Defalut Value, if system.Propery (Java.Version, Java.home ....) does not define the specified key, Return "VAL".
New system parameters
Class method defined by system
System.SetProperty ("ABC", "33");
Use -D option when starting Java Interpreter
Java -Dabc = 88 test
Acquired system parameters
Class Method defined by System
n string val = system.getproperty ("abc");
u Take the system parameters of Key as "ABC", if "ABC" is not defined, then "NULL".
n string val = system.getProperty ("ABC", "33");
u Take the system parameters of Key as "ABC", if "ABC" is not defined, then "33".
Class methods defined in Integer, long and boolean
n Integer Wi = GetInteger ("abc");
u Take the system parameters of KEY "ABC", if "ABC" or Numeric Format is not defined, then return NULL.
N ingeger wi = getinteger ("abc", 33);
u Take the system parameters of Key as "ABC", if "ABC" is not defined, then "33".
l The Math Class
note
n is a final class, so it is not inherited, and all MeBers are Static Members. n Only Private Constructor, so you can't create a Math Object (no Create Math Object)
n Will not throws any exception.
n The result of the resulting number of heterogeneous SQRT () is NaN.
N long, the minimum absolute value of INGEGER is negative.
Example
N sin 45 degree angle value calculation method: (r is the last value)
U Double D = Math.ToraDians (45.5); double r = math.sin (d);
Simple remember
(int, float, long, double)
ABS, MAX, MIN
Strange
Double Random (),
Long Round (Double A), Int Round (Float A)
Only Double
Left other Method
Constants
n static final double e // e (2.718); Static Final Double Pi // π (3.141)
Methods
Triangle function
Double sin (double a) // sIGN OF A
Double Cos (Double A) // Cosign of A
Double Tan (Double A) // Tangent of A
// "a" is an Angle (angle) unit is Radians (radians)
Angle / curvature
Double ToraDians (double deg) // unit is DegRees (degree)
Double TODEGREES (Double Rad) // Unit is Radians (radians)
Secondary
Double Exp (Double A) // EA
Double Pow (Double A, Double B) // Ab
Double SQRT (double a) // a open root number
Chaotic number
Double Random () / / Random value of greater than 0.0 but less than 1.0
Maximum / minimum integer
Minimum integer (Double A) //> = "a" (unconditional entry)
Double Floor (double a) // <= "a" (unconditional)
The integer closest to "a"
Double Rint (double a)
Int round (float a)
Long Round (Double A)
Absolute value
Int ABS (INT A)
Long ABS (long A)
Float ABS (Float A)
Double ABS (Double A)
Large value
Int Max (Int A, Int b)
Long Max (long A, long b)
Float Max (Float A, Float B)
Double Max (Double A, Double B)
Smaller value
INT min (int A, int b)
Long min (long a, long b)
Float min (Float A, Float B)
Double Min (Double A, Double B)
l string and stringbuffer classes
String
n String Object is unstrenomed, "value" after the generation is not changeable, and most of the Method is a new String Object, so there is no setxxxxx () Method in the string class.
n null values cannot call Concat (), otherwise Runtime Error will. String
u toString ()
u static string valueof (Type A) // Type for each Primite Type
Strings length
Instance Method - INT Length ()
Take the string
u String Substring (ING BEGINDEX)
//"Abcdef".substring (1)èbcdef
u String Substring (int Bendex, Int endindex)
//"Abcdef".substring (1, 3 )èbcde
String string string
u string concat (string str) // is attached to the original String
Remove the character
u char charat (int index)
// char ch = "abcd" .Charat (2) è back 'c'
U Void getchars (int srcbegin, int srcend, char [] dst, int dstbeg
// char [] ca = new char [5]; Abcdef.getChars (1, 4, CA, 1);
èCA content is {'/ u0000', 'b', 'c', 'd', '/ u0000'}
u char [] TOCHARARRAY () // Convert String to Char Array
Comparison string
u Boolean Equals (Object Anobject)
u boolean equalsignorecase (String AnotherString)
u Boolean StartSwith (String Prefix)
u Boolean StartSwith (String Prefix, int offset)
u boolean endswith (String Suffix)
u Int ComparetoIgnorecase (String Str)
u Int Compareto (String Argstr)
// int i = str.compareto (argstr) è0 is the same as the Str with Argstr
Looking for strings
u Int indexof (int CH); int CH, INT fromNDEX)
u Int LastIndexOf (int CH); int LastIndexof (int CH, int fromNDEX)
u I int indexof (string str); int indexof (String Str, Int fromNDEX)
u Int LastIndexof (String a); int LastIndexof (String A, INT frIndex)
// Return -1 represents not found
Replacing the character
u string replace (char ildchar, char newcha)
// "abbbcdeb" .replace ('b', 'k') è "akkkcdek"
TRIM
u string Trim ()
// Remove "White Space" on both ends of String (such as blank or '/ t' ...)
intern
u inferne
// Add String to String Pool (if the pool has no STRING OBJECT)
StringBuffer
n StringBuffer is variable. n stringbuffer no override equals ()
Square string
u StringBuffer append (Object Obj)
u stringbuffer append (String STR)
u StringBuffer append (char [] str)
u StringBuffer append (char [] str, int offset, int LEN)
u StringBuffer append (Boolean B); StringBuffer Append (Char C)
U StringBuffer Append (INT I); StringBuffer Append (long L)
u stringbuffer append (float f); StringBuffer Append (double D)
Insert string
U StringBuffer Insert (int index, char [] str, int offset, int LEN)
u StringBuffer Insert (int offset, object obj)
u StringBuffer Insert (int Offset, String STR)
u StringBuffer Insert (int offset, char [] str)
U StringBuffer Insert (int offset, boolean b)
u StringBuffer Insert (int offset, char c)
u StringBuffer Insert (int Offset, INT i)
u StringBuffer Insert (int Offset, long L)
u StringBuffer Insert (int offset, float f)
u StringBuffer Insert (int Offset, Double D)
Delete string
u StringBuffer delete (int start, int end)
u StringBuffer deletecharat (int index)
Substitutive string
u StringBuffer Replace (int Start, int end, string string STR)
Reverse string
u StringBuffer Reverse ()
From: [Garfield's SCJP Read Note]