> I am having trouble getting my program to ignore how information is entered
> (upper/lower case letters). i have been told i have to use IgnoreCase but i
[quoted text clipped - 3 lines]
> "desktop" is written (Desktop, desktop, dESktOP etc...)
> if (type != "desktop")
if ( !type.toLowerCase().equals("desktop") )

Signature
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.
Rhino - 20 Nov 2005 00:01 GMT
>> I am having trouble getting my program to ignore how information is
>> entered
[quoted text clipped - 7 lines]
>
> if ( !type.toLowerCase().equals("desktop") )
Or:
if (!type.equalsIgnoreCase().equals("desktop"))
The mistake you made in your original code is to use the = operator to
compare Strings. The correct technique for comparing Strings is to use the
methods in the String class.
Rhino
Oliver Wong - 22 Nov 2005 17:31 GMT
>>> I am having trouble getting my program to ignore how information is
>>> entered
[quoted text clipped - 15 lines]
> compare Strings. The correct technique for comparing Strings is to use the
> methods in the String class.
Rhino is correct in saying that you should use methods like "equals" or
"equalsIgnoreCase" to compare strings, instead of the "==" or "!=" operator,
but his/her code has a small mistake (probably a typo). It should read:
if (!type.equalsIgnoreCase("desktop"))
- Oliver
DrMatrix - 27 Nov 2005 19:05 GMT
> >>> I am having trouble getting my program to ignore how information is
> >>> entered
[quoted text clipped - 23 lines]
>
> - Oliver
Or better yet use:
if ( !"desktop".equalsIgnoreCase(type) )
This will work even if type == null. if
(!type.equalsIgnoreCase("desktop")) will get a NullPointerException when
type == null.
Knute Johnson - 20 Nov 2005 03:44 GMT
>> I am having trouble getting my program to ignore how information is
>> entered
[quoted text clipped - 7 lines]
>
> if ( !type.toLowerCase().equals("desktop") )
if (!type.equalsIgnoreCase("desktop"))

Signature
Knute Johnson
email s/nospam/knute/
>if (type != "desktop")
see http://mindprod.com/jgloss/gotchas.html#COMPARISON

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.