Reputation: 17
I am trying to convert my string variable to a long variable. The way I am trying for conversion is:
try{
long SessionId =Long.valueOf(myPassword.toString()).longValue();
}catch(NumberFormatException e){
e.printStackTrace();
}
While I am debugging I can see the value of "Long.valueOf(myPassword.toString()).longValue()" but when I try to see the value of "SessionId", debugger says that "SessionId cannot be resolved to a variable". What is the cause of that message ? How can I see the value of "SessionId" while in debug ?
Upvotes: 0
Views: 112
Reputation: 4500
IMHO, when you step after in debugging - you go out of try {} and as SessionId was defined there it's not accessible anymore. Just place some code after it like
try{
long SessionId =Long.valueOf(myPassword.toString()).longValue();
int a = 10; // BREAKPOINT here
} catch(NumberFormatException e) {
e.printStackTrace();
}
and place breakpoint on it.
Upvotes: 2
Reputation: 4382
try this
long SessionId =Long.parseLong(myPassword.toString());
Upvotes: 0
Reputation: 506
You should try this:
long SessionId =Long.parseLong(myPassword.toString());
Upvotes: 0