Package example6;
Import static java.lang.System.out;
Import static Java.util.Arrays.sort;
Import Java.util.Arrays;
Class quietway{
/*1. Static import (Learn)
* You can import static methods or constants directly into the code by using the static import method
* Import static package name;
* such as implementing a calculator, in the math class
* */
public static void Main (string[] args) {
Out.println ("Hello");
Int[] array= {10,20,5,30,12};
Arrays.sort (array);
Sort (array);
System.out.println (arrays.tostring (array));
}
}
Package example6;
Class Zdczx {
/*
* 1. Automatic unboxing: Converting basic data types to wrapper class unpacking: Converting wrapper classes to basic data types
*/
public static void Main (string[] args) {
Java 5.0 (jdk1.6) version is not supported
Automatic Boxing
Integer i = 10;
Automatic unpacking
int m = i;
DoSomething (10);
This function runs as a double, either in the old version or the new version .... (reflects backwards compatibility)
Note: To remember the wrapper classes for the eight basic data types
}
/* How is the Disassembly box implemented in the jdk1.4?
Versions below jdk1.5 cannot be converted automatically and need to be converted manually. However, the manual conversion method is still available in versions higher than JDK 1.5 and is backwards compatible.
*/
public void Test () {
Packing
Integer k=new integer (10);
Unpacking
int N=k.intvalue ();
}
public static void DoSomething (double m) {
System.out.println ("Double ...");
}
public static void DoSomething (Integer N) {
System.out.println ("Integer ...");
}
}
Static import method i.e. automatic disassembly box (Java)