Static import method i.e. automatic disassembly box (Java)

Source: Internet
Author: User
Tags wrapper

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.