Here I have three:
1, directly to the new instances of another class, by way of example to call methods
2, the use of static modification, by class name. Method
The first two I omitted
3, in this class returns a return type for the object's methods
Privatization here to set properties, generating set and get methods
For example:
This class:
Call the class B s () method
public class A(){
1、
B b = new B();
bs (); ----------------------------- first method
2、
B.s();
3、
private B b;
public B getB() {
return b;
}
public void setB(B b) {
this.b= b;
}
This can be:
new A.getB () ==> B corresponds to one example of
new A.getB().s();
If the returned object is a method, it can be:
new A.getB().s2().s()
or
new A.getB().s2().s2().s2().......
}
Another class
public class B(){
public (static )void s(){
System.out.println ( "Hello"); ------------- The second method
}
public B s2(){
B b = new B();
return b;
}
}