Hi, I'm working on this GUI program and I needed to call a method from another class which throws an exception. I tried doing this:
Scanner s;
s=UsingFiles.setFileScanner("board1") throws FileNotFoundException;
But it says I need a semicolon after ("board1"). I did that and it said that "throws FileNotFoundException;" is not a valid expression.
Please help!!!!
Well, I can see you are using Java. I don't know Java. But, from researching the problem, the "throws exception" clause is used when declaring a function. Your code is clearly not declaring a function, it is calling a function and therefore "throws FileNotFoundException" is not valid in this context. The compiler expects an end of line after s=UsingFiles.setFileScanner("board1") thus the reason why it insists you put a semi-colon there and complains about anything extra like "throws FileNotFoundException." I derived that from my 5 minute crash course in Java - so I might be wrong.
Still having this problem?
This topic is from the What the Tech archive and can't take new replies. Geeks to Go is an active, free help community run by volunteers. Post your question there and a person, not a bot, will work through it with you.