我想在運行時追加一個字符串,但此代碼再次添加上一個單詞而不是追加新單詞。在字符串中追加文本
Customer.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寫入,然後按當我寫這辛格結果顯示後再次進入:在控制檯砣砣。 我想顯示ram singh作爲一個字符串。 `public class Request_Message { {0}私人String _Input;
public void setInput(String line) { _Input = line; } public String getInput() { return _Input; }`
它需要從聊天窗口輸入。
有沒有這樣的對象作爲'__Customer'?實例變量的命名方案也很奇怪。大寫字母? – 2010-11-19 08:07:51
爲什麼在示例中的其他任何地方使用_Customer時,您在名爲_ITChatParticipant的對象上使用getCustomerQuestion?這是一個錯字嗎? – Erik 2010-11-19 08:09:19