- Exit (parameter), not 0 indicates an abnormal termination. (Terminate virtual machine)
- Currenttimemillis () returns the current time in milliseconds.
- The array class provides methods for dynamically creating and accessing Java arrays.
Arrays This class contains various methods for manipulating arrays, such as sorting and searching. This class also contains a static factory that allows the array to be viewed as a list.
- The data range of the BigInteger class is much larger than the range of integers.
- BigDecimal class, is immutable, arbitrary precision of the signed decimal number, can solve the problem of data loss. Floating-point numbers are prone to loss of precision, so it is generally better to do so with this class.
- Date: Represents a specific moment, accurate to milliseconds. Date () Creates an object based on the current default millisecond value. A date (long date) creates a day object based on the specified millisecond value.
- Date-à Millisecond Value (GetTime ()) milliseconds value-àdate (1. By constructing method 2.setTime () method).
- Because date formats do not conform to people's habits, appropriate conversions are required. Dateàstring (formatted) [format] method Stringàdate (Parse) "Parse () method" DateFormat: You can format dates and strings, but the class is an abstract class, So use concrete class simpledateformate. (Note: When parsing a string into a date, the format must match the given string format, which refers to the time the Simpledataformat is initialized);
- A method that cannot be found in a subclass can be looked up in the parent class.
- The Calender class is an abstract class that can be converted to a date.
- Public intget (int field) returns the value of the specified calendar field, and the fields in the Calendar class (calender) are static and are of type int. "Gets the month to add one, because the default is 0---11 for 12 months, in order to match the actual, plus a display"
- The calendar is an abstract class that is created with the calendar RightNow =calendar.getinstance (), (which is implemented by polymorphism).
- Common class effects.
Object: is the root class of a class hierarchy, and all classes inherit directly or indirectly from the class.
Scanner: Access to keyboard input data
String: A common operation for strings
Stringbuffer/stringbuilder: String buffer class to improve the operation efficiency of strings
Arrays: A tool class for manipulating arrays
Integer: The int type is encapsulated into an integer type, you can call the method, the most important thing is to convert the string int type.
Character: The char type is encapsulated into the Character type, and the method can be called. Learn a few ways to do it.
Pattern: The compiled representation of the regular expression. The schema object.
Matcher: The Match object.
Math: Classes for math operations
Random: The class that produces the stochastic number
System: Systems class, provides several useful methods
BigInteger: operation of large integers
BigDecimal: The operation of floating-point numbers with this, there is no loss of precision
Date: A class that operates on dates that can be accurate to milliseconds
DateFormat: Formatting for dates or parsing for strings
Calendar: Calendars class, put all the calendar fields to be encapsulated, what to get, and then splicing.
- Get the number of days in February of any year
Importjava.util.Calendar;
Import Java.util.Scanner;
public class Eryue {
publicstatic void Main (string[] args) {
Scannersc=new Scanner (system.in);
System.out.println ("Please enter the year you want to enter:");
Intyear=sc.nextint ();
Calendarc=calendar.getinstance ();//Create Object
C.set (year,2,1); first day of//3 month
C.add (calendar.date,-1); date minus one day
System.out.println (C.get (calendar.date)); Get date
}
}
- The question of how many days to live
. package Zhongjie;
. importjava.text.ParseException;
importJava.text.SimpleDateFormat;
. Import Java.util.Calendar;
import java.util.Date;
. import Java.util.Scanner;
Public class Alldate {
Public Static void Main (string[] args)throws ParseException
{
Scanner sc=New Scanner (System. in);
System. out. println ("Please enter your date of birth:");
String Oldyear=sc.nextline ();
SimpleDateFormat s=New SimpleDateFormat ("Yyyy-mm-dd");
Date D=s.parse (oldyear);
long o=d.gettime ();
Calendar c=calendar.getinstance ();
Long N=system. Currenttimemillis ();
System. out. println ("You are already alive" + (N-o)/1000/60/60/24+ "Days");
}
}
36. The difference between sets and arrays: the length of the array is fixed, the length of the collection is variable, the array stores the elements of the same type, and the collection can store different types of elements. An array can store either the base data type or the reference type, and the collection can only store reference types.
37 Iteration Simple Comprehension is traversal (traversal of the collection). The length function of the collection is size (), not length (), which is to be remembered.
38. The removal of a collection returns True if one is removed, not all of which return true. Only contains all the elements that are called inclusions, and one of the two inclusions does not count as inclusions.
39. The intersection function of the set Retainall () The note point: Suppose there is a A, a two set, A to B intersection, the final result is saved in a, B is unchanged. The return value is a Boolean type, and the data in a change is ture, and no change is flase.
---------------"to Be continued
JAVA Notes (eight)