Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

equalsIgnoreCase

807599May 7 2007 — edited May 7 2007
public void readInput()
	{
		System.out.println("Please enter some information on your character: ");
		System.out.print("Name: ");
		name = keyboard.nextLine();
		do
		{
			System.out.print("Health (0.0 - 100.0): ");
			health = keyboard.nextDouble();
		}
		while (health < 0.0 || health > 100.0);
			
		do
		{
			System.out.print("Armor (0.0 - 100.0): ");
			armor = keyboard.nextDouble();
		}
		while (armor < 0.0 || armor > 100.0);	
		
		System.out.print("Good or Evil?: ");
			goodOrEvil = keyboard.nextLine();
		
		**while (goodOrEvil.equalsIgnoreCase != good
			**		|| goodOrEvil.equalsIgnoreCase != evil)
		{
			System.out.print("Good or Evil?: ");
			goodOrEvil = keyboard.nextLine();
		}
					
		do
		{
			System.out.print("Ammo (1 - 50): ");
			ammo = keyboard.nextInt();
		}
		while (ammo < 1 || ammo > 50);
I'm so lost right now lol. I keep getting compiler errors when I compile this. I'm not really sure why, but I'm sure someone else can spot my problem pretty much instantly

Comments

807599
I'm sorry...I need to know what is wrong with the starred area. I would greatly appreciate it if someone would look over it
569573
Check the API document
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#equalsIgnoreCase(java.lang.String)
// sample
if (str1.equalsIgnoreCase("Continue") {
// case true
} else {
// case false
]
807599
G:\Introduction to Java\Character.java:33: cannot find symbol
symbol : variable equalsIgnoreCase
location: class java.lang.String
while (goodOrEvil.equalsIgnoreCase != good
^
G:\Introduction to Java\Character.java:33: cannot find symbol
symbol : variable good
location: class Character
while (goodOrEvil.equalsIgnoreCase != good
^
G:\Introduction to Java\Character.java:34: cannot find symbol
symbol : variable equalsIgnoreCase
location: class java.lang.String
|| goodOrEvil.equalsIgnoreCase != evil)
^
G:\Introduction to Java\Character.java:34: cannot find symbol
symbol : variable evil
location: class Character
|| goodOrEvil.equalsIgnoreCase != evil)
^
4 errors

These are the errors that I am getting. I understand what it is talking about...but don't understand why I am getting them
807599
Are you trying to achieve something like this?
while ( ! goodOrEvil.equalsIgnoreCase("good"))
807599
oh my.....quotations....didnt think about that....slipped my mind....let me put those in right fast and try again
807599
your method worked....just curious....why wouldn't this work
while (goodOrEvil.equalsIgnoreCase != "good"
807599
your method worked....just curious....why wouldn't
this work

while (goodOrEvil.equalsIgnoreCase != "good"
The short answer is that you can't just make up your own syntax.
807599
I realize that now....lol.....I was staring and staring at it trying to figure out WHY it didn't work......didn't occur to me that it wasn't even legal to write that...thanks a lot for your help
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 4 2007
Added on May 7 2007
10 comments
389 views