Hi,
I already know you can't compare strings using ==, so I've tried using the
following code:-
if (lblcurPass.getText().equals(curPass))
However, even when lblcurPass and curPass are the same it will always return
false. I've also tried compareTo, and that returns false.
Using System.out.print I can display the two passwords, and they are indeed
the same on screen.
Comparing two strings in a seperate small applet also works fine
Don't know how I've fixed it, but if I copy the strings into new empty
strings it works.
And that's why I hate Java
"Richard Kirkcaldy" <java.@127.0.0.1> wrote in message
news:3cca960e$1@10.1.10.29...
>
> Hi,
> I already know you can't compare strings using ==, so I've tried using the
> following code:-
>
> if (lblcurPass.getText().equals(curPass))
>
> However, even when lblcurPass and curPass are the same it will always
return
> false. I've also tried compareTo, and that returns false.
> Using System.out.print I can display the two passwords, and they are
indeed
> the same on screen.
> Comparing two strings in a seperate small applet also works fine
>
> What's going wrong?
>
> --
> Richard Kirkcaldy
> richard@technical-power.co.uk
04-29-2002, 07:44 AM
MarkN
Re: comparing strings
"Richard Kirkcaldy" <java.@127.0.0.1> wrote:
>
>Hi,
>I already know you can't compare strings using ==, so I've tried using the
>following code:-
>
>if (lblcurPass.getText().equals(curPass))
>
>However, even when lblcurPass and curPass are the same it will always return
>false. I've also tried compareTo, and that returns false.
>Using System.out.print I can display the two passwords, and they are indeed
>the same on screen.
>Comparing two strings in a seperate small applet also works fine
>
>What's going wrong?
>
>--
>Richard Kirkcaldy
>richard@technical-power.co.uk
Try doing a .trim() on both strings.
Why is the password in a Label or is that just your naming convention?
04-29-2002, 07:49 AM
markN
Re: comparing strings
There must be a reasonable explaination.
You shouldn't store values in labels or text boxes anyway. You should be
using a domain object.
Don't blame your lack of understanding on Java. Don't like Java? Don't
go near VB.Net or C#.
05-01-2002, 09:20 PM
Soft Solution System Limited
Re: comparing strings
Are you using the JPasswordField?
use the following to get the actual string of the password:
"Richard Kirkcaldy" <richard@technical-power.co.uk> wrote:
>Don't know how I've fixed it, but if I copy the strings into new empty
>strings it works.
>
>And that's why I hate Java
>
>"Richard Kirkcaldy" <java.@127.0.0.1> wrote in message
>news:3cca960e$1@10.1.10.29...
>>
>> Hi,
>> I already know you can't compare strings using ==, so I've tried using
the
>> following code:-
>>
>> if (lblcurPass.getText().equals(curPass))
>>
>> However, even when lblcurPass and curPass are the same it will always
>return
>> false. I've also tried compareTo, and that returns false.
>> Using System.out.print I can display the two passwords, and they are
>indeed
>> the same on screen.
>> Comparing two strings in a seperate small applet also works fine
>>
>> What's going wrong?
>>
>> --
>> Richard Kirkcaldy
>> richard@technical-power.co.uk
>
>
Check the lengths of the strings, I guarantee they are not the same. There
probably is a space or character messing up the comparison.