public void processMessage(Chat chat, Message me开发者_运维技巧ssage) {
if (message.getType() == Message.Type.chat)
System.out.println(chat.getParticipant() + " says: "+ message.getBody());
**processmsg** = message.getBody();
System.out.println("Message from Friend -----:"+**processmsg**);
}
Hi.how to use this processmsg String in another method.if i use outside this method i get null value. plz reply soon
Store processmsg as an instance variable in the class that contains processMessage
class Foo {
private String processmsg;
public void processMessage(Chat char, Message message) {
processmsg = message.getBody();
}
public void bar() {
// do whatever you want
}
}
Obviously you'll need to check that it's been assigned and so on before you use it (e.g. you couldn't use bar before processMessage), but you get the idea!
精彩评论