I'm a Newbie to Java - am trying to explore the relationship between objects / classes & have run into a roadblock which I'm sure will seem retarded to folks with more experience. I wrote a very simple program below to call another method & print text 10 times after the user inputs 'Y'. I know its not necessary to put the loop in another class but I'm doing it to develop my understanding however when I compile it I get an error msg: 'Syntax error on token "throws", throw expected'.
I've declared the exception at the start so not sure why I'm getting this...please help I'd appreciate any info!
class MyTest {
public static void main(String args[]) {
throws java.io.IOException; {
char ch, y = 'Y';
OutputIncrements input = new OutputIncrements();
System.out.println("Enter Y or N");
ch = (char) System.in.read(); // get a char
System.out.println("You entered: " + ch);
if(ch == y) input.range();
}
}
class OutputIncrements {
void range() {
for(int i=0; i<10; i++) {
System.out.println("This loops 10 times");
if(i == 5) System.out.println("This is the 5th time");
}
}
}
}