An interface defines only the methods to be used for derivation, but the concrete implementation of the method depends entirely on the derived class. If a class is defined in a package, then the packages statement should be in the first row of the source file. If the source file contains an import statement, it should be placed between the package statement and the class definition. If there is no package statement, the import statement should be first in the source file. The import statement and the package statement are valid for all classes defined in the source file. In the same source file, you cannot give different package declarations to different classes. Byte:1 byte -128~127, space saving in large arrays short:2 bytes -32768~32767int:4 bytes -2^31~2^31-1float:4 bytes Float f1 = 12.4fchar:2 Bytes//double S Ystem.out.println ("Basic type: Double bits number:" + double.size); SYSTEM.OUT.PRINTLN ("Packing class: Java.lang.Double"); SYSTEM.OUT.PRINTLN ("Minimum value: double.min_value=" + double.min_value); SYSTEM.OUT.PRINTLN ("Maximum value: double.max_value=" + double.max_value); System.out.println (); Char System.out.println ("base type: char bits number:" + character.size); SYSTEM.OUT.PRINTLN ("Packing class: Java.lang.Character"); Output Character.min_value to console System.out.println ("min: character.min_value=" + (int) in numeric form rather than as a character) Character.min_value); Output Character.max_value to console System.out.println ("Maximum: character.max_value=") in numerical form instead of as a character + (int) character.max_value); Instance variables can be accessed directly from the variable name. However, in static methods and other classes, you should use fully qualified names: Obejectreference.variablename class variables are also known as static variables, and the static keyword declaration in a class has similar visibility to instance variables. But in order to be visible to the consumer of a class, most static variables declared as public type static variables can be accessed by: Classname.variablename The class variable name must use uppercase when the class variable is declared as public static final type. If a static variable is not a public and final type, it is named in the same manner as the instance variable and the local variable//enumeration can be declared or declared in the class individually. Methods, variables, and constructors can also be defined in enumerations.
Enum Typeclass freshjuice {enum freshjuicesize{SMALL, Meduim, LARGE}freshjuicesize size;} public class Test {//constant use capitals for namefinal double PXY = 666;//class variable (static variable) private Stati C Double salary;//capitalize. Because public static finalpublic static final String DEPARTMENT = "Development";p ublic static void Main (String []args) { Freshjuice test = new Freshjuice ();//reference:ClassName.enumVariable.nametest.size = FreshJuice.FreshJuiceSize.MEDUIM; System.out.println (test.size); salary = 1000; System.out.println (department+salary);}}
java-basic-2-