hi, i'm making a simple program where it when you type a name of soemthing from a video game it will give you a brief description, i'll be using if and else statements, here is what i have so far.

import java.util.Scanner;
public class WoW
{
public static void main(String[] args)
{
String classname;
String rogue;
Scanner inputDevice = new Scanner(System.in);
System.out.println("Welcome");
System.out.println("Please enter a WoW class");
classname = inputDevice.nextLine();
if(classname == rogue)
{
System.out.println("A rogue uses stealth and daggers to destroy it's opponent.");
}
else
{
System.out.println("bye bye");
}
}
}

the rogue string is what im having trouble with, i believe im declaring rogue wrongly im not sure how i would go about declaring it. I want rogue to be what the person will type in in a literal sense.

Recommended Answers

All 2 Replies

You can just use

if(classname.equalsIgnoreCase("rogue")){

it worked, thank you :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.