System: The methods and attributes in the class are static.
Obtain system property information: Properties getproprerties ();
Class systemdemo {
Public static void main (string [] ARGs ){
Properties prop = system. getproperties (); // returns a double row set.
/* Java. Lang. Object
Java. util. dictionary <K, V>
Java. util. hashtable <object, Object>
Java. util. properties */
// Obtain the specified property information
String value = system. getproperty ("OS. Name ");
System. Out. println ("value:" + value );
/* For (Object OBJ: prop. keyset ()){
String value = (string) prop. Get (OBJ );
System. Out. println (OBJ + ":" + value );
}*/
// Customize some unique information in the system
System. setproperty ("KK", "FF ");
// Some attribute information is dynamically loaded when JVM is enabled. In the console, Java-DKK = FF systemdemo
String v = string. getproperty ("");
System. Out. Print ("V =" + V );
}
}
Runtime object: The constructor is not provided in this class, indicating that you cannot create an object. The methods in this class are static, but there are non-static methods in this class, this class must have a method to return this class object.
The method is static and the return value is of this class type. Static runtime getruntime ();
/*
Java. Long. Object
Java. Lang. Runtime
*/
Import java. util .*;
Class runtimedemo
{
Public static void main (string [] ARGs) throws exception
{
Runtime r = runtime. getruntime ();
Process p=r.exe C ("notepad.exe fdsdd"); // In addition to notepadProgramYou can also add some content later, separated by Spaces
Thread. Sleep (4000 );
P. Destroy (); // kill the sub-process
}
}
Date object: ClassDate
Indicates a specific moment, accurate to milliseconds.
Import java. util .*;
Import java. Text .*;
Class datedemo
{
Public static void main (string [] ARGs) throws exception
{
Date d = new date (); // The printed date is messy and needs to be formatted
System. Out. println (d );
// Encapsulate the mode in the simpledateformat object
Simpledateformat SDF = new simpledateformat ("yyyy-mm-dd ");
// Format the specified date object in format
String time = SDF. Format (d );
System. Out. println (time );
}
}
Calendar: the object that replaces the method in the date object
Import java. util .*;
Import java. Text .*;
Class calendardemo
{
Public static void main (string [] ARGs) // print the formatted year, month, and day
{
// Method ();
Calendar c = calendar. getinstance ();
C. Set (2010,3, 23); // you can specify a date.
Printcalendar (C );
System. Out. println ();
C. Add (calendar. Month,-2); // value, offset
Printcalendar (C );
}
Public static void Sop (Object OBJ)
{
System. Out. Print (OBJ );
}
/* Public static void method () // print the formatted year, month, and day
{
Calendar c = calendar. getinstance ();
String [] Mons = {"January", "February", "March", "April ",
"August May", "August June", "August July", "August ",
"August September", "August October", "August November", "August December "};
String [] weeks = {"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday "}; // The value starts from 0. The week value is either reduced by one or the first value is null.
Int Index = C. Get (calendar. month); // the number of days in the month is an integer.
Int index2 = C. Get (calendar. day_of_week );
Sop (C. Get (calendar. Year) + "year ");
Sop (Mons [Index]);
Sop (C. Get (calendar. day_of_month) + "day ");
Sop (weeks [index2]);
}*/
Public static void printcalendar (calendar C)
{
String [] Mons = {"January", "February", "March", "April ",
"August May", "August June", "August July", "August ",
"August September", "August October", "August November", "August December "};
String [] weeks = {"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday "}; // The value starts from 0. The week value is either reduced by one or the first value is null.
Int Index = C. Get (calendar. month); // the number of days in the month is an integer.
Int index2 = C. Get (calendar. day_of_week );
Sop (C. Get (calendar. Year) + "year ");
Sop (Mons [Index]);
Sop (C. Get (calendar. day_of_month) + "day ");
Sop (weeks [index2]);
}
}
Math:
Import java. util .*;
Import java. Text .*;
Class mathdemo
{
Public static void main (string [] ARGs) // print the formatted year, month, and day
{
Double D = math. Ceil (12.34); // returns the smallest integer value greater than the specified data.
Sop ("d =" + D );
Double d1 = math. Floor (12.34); // returns the maximum integer less than the specified value.
Sop ("d1 =" + D1 );
Long L = math. Round (12.34); // rounding
Sop ("L =" + l );
Double D3 = math. Pow (2, 4); // returns the 4 power of 2.
Sop ("D3 =" + D3 );
For (INT x = 0; x <10; X ++) // returns the random number of 010.
Sop (D1 );
}
}
Public static void Sop (Object OBJ)
{
System. Out. Print (OBJ );
}
}