1. Inner class
eg
public class example{
public static void Main (string[] args) {
FirstClass fc = new FirstClass ();
Firstclass.secondclass sc = fc.new secondclass ();
Sc.out (1);
}
}
Class firstclass{
Class secondclass{
public void out (int a) {
System.out.println (a+=3);
}
}
}
2. Construction method
The constructor method name and class name are exactly the same
The constructor does not return a value, not even void, which is different from other methods
The construction method does not appear explicitly, and it is implicitly present. If we do not define a constructor method in the class, the system generates a default, parameterless construction method for use
Construction methods must be called when generating objects with a class
In the constructor method, the default is to use the form of no parameters. If only a parameter is in the form, the default parameterless construction method is not generated. It is also important to pay attention to the value of the argument when the build object calls the constructor method
eg
public class example{
public static void Main (string[] args) {
ABC A = new ABC (); There's a problem here, you can't create an object
}
}
Class abc{
Public ABC (int i, int j) {
System.out.println (I+J);
}
}
[Java] Classes and objects