A. Java API
1.java.lang
Java language Pack (containing classes such as String, StringBuffer, Integer, math, math, System, and so on), in any class, the classes in that package will be imported automatically
2.java.util
Contains a number of useful tools (including list, calendar, date, and other classes)
3.java.awt
Graphical User Interface Pack
4.java.io
Classes that provide multiple input/output functions
The difference between equals and "= =":
equals from a value point of view whether it is consistent (judging whether it is consistent)
"= =" Judging from the memory address angle is consistent (judging is not a thing)
Two. Packing class
1. Basic data type conversion to wrapper class (by construction method)
int x = 500;
Integer y = new integer (x);
2. String conversion to wrapper class (by construction method or wrapper class valueof (string s))
string is converted to wrapper class by construction method
String x= "500";
Integer y= new Integer (x);
The string is converted to a wrapper class by wrapping the valueof (string s) of the class
String x= "500";
Integer y= integer.valueof (x);
3. wrapper class converted to basic data type
Wrapper classes are converted to basic data types through the Xxxvalue () method
Integer x= new Integer (500);
int y= x.intvalue ();
4. wrapper class converted to string
Wrapper classes are converted to strings by the ToString () method
Integer x= new Integer (500);
String y= x.tostring ();
5. string conversion to base data type
String converted to base data type by PARSEXXX (string s) method
String x= "500";
int y= integer.parsetint (x);
6. Automatic box packing and automatic unpacking
When the basic data types and corresponding wrapper class conversions are performed, the system automatically introduces the JDK since the 5.0 release, facilitating program writing
int x= 500;
Integer y= x;
int n = y;
Three. String class
1. The string is one of the most common data types we use in programming, and its representation can be divided into two types: string and StringBuffer
2. It is not part of 8 basic data types, but a reference type
The 3.String object represents a set of immutable Unicode character sequences, and any modifications to it actually produce a new string, and the contents of the string object cannot be changed once initialized.
4.StringBuffer object represents a set of customizable Unicode character sequences
5. At the same time, the String class is the final type of class
StringBuffer class
1.StringBuffer class for strings that can be changed by content
2. You can use StringBuffer to dynamically manipulate the contents of a string without generating additional objects
String differs from StringBuffer:
Content initialization in a String class object cannot be changed, the contents of the StringBuffer class object can be changed
? Requirements: String and StringBuffer convert each other
1 Packagedemo;2 /*conversion between string and StringBuffer3 * String --StringBuffer4 * Way One: Construction method5 * Way two: Through the Append method6 * StringBuffer, String7 * Way One: Through the construction method8 * Way Two: by ToString Method9 * */Ten Public classStringandstringbufferswitch { One Public Static voidMain (string[] args) { A //String --StringBuffer - //Create a String object -String str = "Hi java!"; the System.out.println (str); - - //Mode One: Construction method -StringBuffer buffer =NewStringBuffer (str); + System.out.println (buffer); - + //Way two: Through the Append method AStringBuffer buffer2 =NewStringBuffer (); at buffer2.append (str); - System.out.println (buffer2); - - //StringBuffer, String - //Create a StringBuffer object -StringBuffer Buffer3 =NewStringBuffer (); inBuffer3.append ("Happy Birthday java!"); - System.out.println (buffer3); to + //Way One: Through the construction method -String str2 =NewString (BUFFER3); the System.out.println (str2); * $ //Way two: Through the ToString MethodPanax NotoginsengString STR3 =buffer3.tostring (); - System.out.println (STR3); the } +}
Four. Date class
SimpleDateFormat class
1.java.text.simpledateformat
2. A specific class that formats and analyzes dates in a language-related manner. is a subclass of the abstract class Java.text.DateFormat class
3.SimpleDateFormat allows you to select any user-defined pattern of date-time formats
Use of the SimpleDateFormat class:
Get an instance of SimpleDateFormat
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
Get current system time
New Date ();
Formats a date as a specified string
Sdf.format (New Date ());
Converts a formatted string into a Date object
Sdf.parse ("2011-07-16");
Construction Method Summary
|
Construction Method Summary |
|
Integer (int value)
Constructs a newly assigned Integer object that represents the specified int value. |
|
|
Integer (String s)
Constructs a newly assigned Integer object that represents the int value indicated by the String parameter. |
|
|
Int |
CompareTo (Integer Anotherinteger)
Compares two Integer objects on a number. |
|
Int |
Intvalue ()
Convert an integer type to an int type |
|
static int |
parseint (String s)
Converts a string into a base data type. |
Character
|
Static Boolean |
IsDigit (Char ch)
Determines whether the specified character is a number. |
|
Static Boolean |
Isletter (Char ch)
Determines whether the specified character is a letter. |
|
Static Boolean |
Isletter (int codepoint)
Determines whether the specified character (Unicode code point) is a letter. |
|
Static Boolean |
Isletterordigit (int codepoint)
Determines whether the specified character (Unicode code point) is a letter or a number. |
String
|
String |
Concat (String str)
Connects the specified string to the end of this string. Append at end |
|
Char |
charAt (int index)
Returns the char value at the specified index. |
|
Boolean |
Contains (charsequence s)
Returns True when and only if this string contains a sequence of specified char values. |
|
Boolean |
EndsWith (String suffix)
Tests whether this string ends with the specified suffix. |
|
Boolean |
IsEmpty ()
Returns true if and only if length () is 0 o'clock. |
|
Boolean |
StartsWith (String prefix)
Tests whether this string starts with the specified prefix. |
|
String |
substring (int beginindex)
Returns a new string that is a substring of this string. |
|
String |
Trim ()
Remove the leading and trailing spaces of a string |
Java Advanced section-Tools Class (1)