【发布时间】:2010-11-19 07:59:08
【问题描述】:
我想在运行时附加一个字符串,但是这段代码再次添加了前一个单词而不是附加新单词。
客户.java:
public String getCustomerQuestion() {
return CustomerQuestion;
}
public void setCustomerQuestion(String customerQuestion) {
CustomerQuestion = customerQuestion;
}
public void appendmessage(String msg){
CustomerQuestion = CustomerQuestion +" "+ msg;
}
Main.java:
Customer _Customer =new Customer();
Request_Message Request= new Request_Message;
_Customer.setCustomerQuestion(Request.getInput());
String _string=Request.getInput();
_Customer.appendmessage(_string);
String str=__Customer.getCustomerQuestion();
System.out.println("now new Question() is"+str);
当我写 ram 时,当我写 singh 时再次按下回车,它会显示结果:控制台上的 ram ram。 我想将显示 ram singh 显示为字符串。 `公共类Request_Message { { 私有字符串_Input;
public void setInput(字符串行) { _输入=线; } 公共字符串 getInput() { 返回_输入; }`
它接受来自聊天窗口的输入。
【问题讨论】:
-
没有
__Customer这样的对象吗?实例变量的命名方案也很奇怪。大写字母? -
在示例中的其他任何地方都使用 _Customer 时,为什么要对名为 _ITChatParticipant 的对象使用 getCustomerQuestion?是不是笔误?