nStudent
asked on
Why this not working !!!
Hello,
Question::
method that work...........
String str=object.getAccountId(). trim(); //this question is on the line
if(str.equals("12345"))
{
System.out.print("12345");
}
else
{
System.out.print("Error");
}
method that doesn't work......
if(object.getAccountId().t rim().equa ls("12345" )) // this line does not work why this happen????
System.out.print("12345");
else
System.out.print("error");
Thk U
From newbie
Question::
method that work...........
String str=object.getAccountId().
if(str.equals("12345"))
{
System.out.print("12345");
}
else
{
System.out.print("Error");
}
method that doesn't work......
if(object.getAccountId().t
System.out.print("12345");
else
System.out.print("error");
Thk U
From newbie
shouldn't be any difference
>> this line does not work
You mean?
You mean?
There's no difference between those two examples.
Second should work too, perhaps the accountId was not 12345 when you tested the second one? ;)
Second should work too, perhaps the accountId was not 12345 when you tested the second one? ;)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or before the equals()
hi,
depending on what getAccountId returns :
/*** returns object : ***/
if (object.getAccountId().toS tring().tr im().equal s("12345") )
System.out.print("12345");
else
System.out.print("error");
/*** returns int or similar : ***/
if ((new Integer(object.getAccountI d())).toSt ring().tri m().equals ("12345"))
System.out.print("12345");
else
System.out.print("error");
is any of these better ?
stephane.
depending on what getAccountId returns :
/*** returns object : ***/
if (object.getAccountId().toS
System.out.print("12345");
else
System.out.print("error");
/*** returns int or similar : ***/
if ((new Integer(object.getAccountI
System.out.print("12345");
else
System.out.print("error");
is any of these better ?
stephane.