- Java code
public class helloJava {String say="我要学会";public static void main(String[] arge){ String say="aaaaaa"; System.out.println("你好,java"+say); System.out.println("你好,java"+say);}}
现在输出的是main方法中的say 我现在想输出"我要学会"这个say,该如何输出呢?
------解决方案--------------------------------------------------------
public class HelloJava {
private String say="我要学会";
public String getSay() {
return say;
}
public void setSay(String say) {
this.say = say;
}
public static void main(String[] arge){
String say="aaaaaa";
HelloJava hello=new HelloJava();
// System.out.println("你好,java"+say);
System.out.println("你好,java"+hello.getSay());
}
}