here's my code
int cclass;
System.out.println("Please choose your character class");
System.out.println("1) Fighter");
System.out.println("2) Theif");
System.out.println("3) Mage");
try
{
cclass = keyboard.nextInt();
}
catch ( InputMismatchException inputMismatchException )
{
System.err.printf( "\nException: %s\n",
inputMismatchException );
scanner.nextLine();
System.out.println(
"You must an integer. Please try again.\n" );
}
f (cclass <=1)//the < is to solve the need for boolean in that statement
{
cclassname = Fighter;
}
else if (cclass <=2)
{
cclassname = Theif;
}
else
{
cclassname = Mage;
}//the new variable cclassname is used in dialogue inside my game and is already initialized using the String method
//Also, all of it is inside a public static void main(String[] args) method with import.java.util.*; at the topWhat I get when I compile it is variable cclass might not have been initialized... help?

Help



Back to top










