Java jdk6 static Import

Source: Internet
Author: User

The Java language introduces the import of static data to simplify the use of static attributes and methods. After importing static information, you can use methods/attributes without limiting the method/attribute to the class name. For example, by importing static members of the math class, you can write ABS or SQRT instead of math. ABS and math. SQRT.

 
Colors. Java
 
Package SCY; public class colors {public static int white = 0; public static int black = 1; public static int Red = 2 ;}

Statictest. Java

PackageSCY;
Import StaticSCY. colors.*;
Public ClassStatictest {

Public Static VoidMain (string [] ARGs ){
System. Out. println (red );
}
}

Running result: 2


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.