Jdk5.0 new feature series-4. Static Import

Source: Internet
Author: User
Tags math min

 

/**

* Static import: it refers to the static methods and static variables that can be imported. You do not need to specify the class name during use,

* You can use these static methods and static variables to be imported. This is static import.

* When writing an Import Statement, you can locate a static method or static variable (previously located to a class)

* Wildcard characters (*) can be used to import all static methods and static variables of the class.

* Duplicate names of static methods and static variables are not allowed.

*/

Import StaticJava. Lang. Math.Max; // Import the max method of math

Import StaticJava. Lang. Math.Min; // Import the math min Method

Import StaticJava. Lang. Integer. *; // imports all the static methods and static attributes of integer.

Public ClassStaticimport {

Public Static VoidMain (string [] ARGs ){

// Use the static math method for static Import

System.Out. Println (Max(5, 10 ));

System.Out. Println (Min(5, 10 ));

// Use the integer static method for static Import

System.Out. Println (Parseint("55544555 "));

System.Out. Println (Tobinarystring(2354 ));

// Use the static attributes of integer through static Import

System.Out. Println (Max_value);

System.Out. Println (Min_value);

}

}

 

 

 

 

Related Article

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.