Since 'A's are an object, you need a constructor. So you would likely have something like:
public A(String name){
this.name = name;
}
After this, you need to overwrite toString(), since 'A's are objects and printing them normally will not work. Thus, you would then need:
public String toString(){
return this.name;
}
Thus, when you call SoPL(), it will run this version instead of Object.toString()
Consider method with name A, where you are creating an object of A and can pass the parameter as a string, then the method A can return a string which belongs to the variable
called name = myvalue;
It Means
public A(String name){
this.name = name;}
String name = myvalue;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.