如何使用 class 的方法A
在 class 中设置 class 参数的值?B
setvarA
A
public class A{
String varA;
public String getvarA() {
return varA;
}
public void setvarA(String varA) {
this.varA=varA;
}
}
public class B{
String name = "abc";
A objA = new A();
objA.setvarA(name) ; ## THIS LINES THROWS AN ERROR
}
错误是:
Syntax error on token "name", VariableDeclaratorId expected after this token and Syntax error on token(s), misplaced constructs