Illegal start of expression
trying to take char input and display whether a vowel
i get error saying that enum has illegal start of expression and that it must not be local
boolean.java:6: illegal start of expression
public enum vowels
^
boolean.java:6:enum types must not be local
public enum vowels
^
im really new and i dont know what ive done
Code Java:
public class Boolean {
public static void main (String[] args) {
public enum vowels {
A('a'),E('e'),I('i'),O('o'),U('u');
}
char letterinput;
boolean isVowel;
System.out.print("Enter a letter: ");
int c = System.in.read();
letterinput = (char)c;
while(System.in.available() > 0) {
System.in.read();
}
if (letterinput == vowels) {
isVowel = true;
System.out.println(letterinput + "is a vowel");
} else {
isVowel = false;
System.out.println(letterinput + "is not a vowel");
}
}
}
Re: Illegal start of expression
Please copy the full text of the error messages and post them here.
Try moving the enum outside of the method.
Also see the tutorial: http://docs.oracle.com/javase/tutori...vaOO/enum.html
BTW Boolean is the name of a java SE class. It'd be less confusing if you used your own name for your class.
Re: Illegal start of expression
I have seen the tutorial and I`m pretty sure I have copied the syntax to the letter unless you actually have to have each constant on a new line, also upon moving the enum outside the method the compiler then fails to recognise the vowels identifier
Re: Illegal start of expression
Your usage of vowels needs some more stuff: add on one of the enum names like A: vowels.A
Post the full text of any error messages. I don't remember "fails to recognize" as a compiler error.