你看看下面那个简单的例子是否是你想要的:
public class GetReturn {
private String str;
public void setStr(String str) {
this.str = str;
}
//用于获取str的值
public String getStr() {
return str;
}
public static void main(String[] args) {
String s = "";
GetReturn g = new GetReturn();
//设置str的值
g.setStr("青菜萝卜");
//接收返回值
s = g.getStr();
System.out.println("调用访问接收到的返回值为:"+s);
}
}