Java2 learning manual

xiaoxiao2021-03-06  67

1. Problems with access: A class may only have two access level: default and public. By default - it can only be accessed by other code of the same package. (You can only have a class declaration in a file to be public, which is declared as the class name of the public, and the file name.) 2. Butfact interface specifies what is doing. Instead of specifying how it does it. It does not include methods Body. A class can be implemented in a class. The interface is designed to support the running dynamic method solution. It separates the defaults of the method or method series from the class level. The method defined in the interface does not have the default value . Each class containing the interface must implement all methods of the interface. The default access to the interface is accessible to all the code in the package. 3 Implement interface: imports classname: Access class classname [Extends superclass] [Implements Interface, [Implements Interface Interface ....]] {// Class Body;} When an interface method is implemented. This method must be declared as public.4. Implement the interface through the interface: You can define the variable into an object reference to the interface. All implementations An example of the class of the interface can be referenced by such a variable. Class classname1 {public static void main (String [] args) {InterfaceName Variablename = new classname1 (); variablename.MENTH (); // Call with a variable Interface method. Public static void main (string [] args) {interfaceName1 (); classname2 ob = new classname2 (); c.MENTH (); c = ob; // This is a focus. A polymorphism is achieved. Variable "C" can take any instance of the class of the interface. 5. Enter output byte stream: IPUTSTREAM, OUTSTREAM (Abstract class) Character stream: Reader, Writer Predetermined objects related to three input outputs in the System object: in, out, err (static, final) system. IN => InputStream System.err and System.out => PrintStream InputStreamReader objects can convert bytes into characters. BufferedReader Br = New BufferedReader (NEW INPUTSTREAM (ISTEM (IN)); == is to determine if the two subtringent is in the same storage location. Equals (Object Obj) Returns True if the string is equal to OBJ.

Definition format of array: type var_name []; 'just declaration, no memory space array-var = new type [size];' allocating space int monty_days [] = new int [12]; int [] A1 = {1, 2, 3, 4, 5};

转载请注明原文地址:https://www.9cbs.com/read-110743.html

New Post(0)