1.1.an algorithm for number inversion
A take the reverse,~a=-(a+1). As
~5=-6,~(-8)=7
1.2. access control characters for classes in Java
(the modifier for a class has public,default,abstract,final, The modifiers for the method are public,default,protected, Private)
Public: This class can be accessed by an external package
Default(Default): This class can only be accessed by this package
Protected: This class can only be accessed by the quilt class
Private: This class cannot be accessed by any class
1.3.the difference between static and non-static methods
static methods do not need to create an instance of the class to be used, and a non-static method must create an instance of the class to be used, that is , the new object, and the method is called through the object
1.4.Static Variables
Static variables are static storage and must be defined outside the function, and after being called by a dynamic function, the static variable is the value after the change. Does not return to the initialized value because the function call ends. Such as:
Package Hello;
public class hello{
static int a=1;
int fun (int n) {
A=a*n;
Returm A;
}
public static void Main (string[] args) {
Hello h=new hello ();
for (int i=1;i<4;i++)
System.out.println (H2.fun (i));
}
}
}
1.1.Interfaces and Classes
multiple inheritance properties are forbidden in the Java programming language, but can be used to help extend the method through an interface. A large number of solid and methods can be defined in the interface. But the method is only a declaration, there is no specific implementation, the use of the interface classes themselves have implemented these methods. The difference between an interface and a = class is that:
(1) There is no declaration of variables, but can be defined as solid;
Only the declaration of the method, there is no implementation of the method.
Java Learning Notes (i)