This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
So I'm pretty new to Java and this is my first semester. Can anybody help me out and tell me what I'm getting wrong here in my "okUserName() method"? I keep trying to work on it but I'm definitely stumped. Also I have an alternate driver class with a main method & a file in the same folder, but everything is perfect there.
*mind the awful indentation I just copy and pasted from my ide.
I don't know whether i understood completly your actual problem or not.
But when i take the code to my IDE, i found two compiler error.
1) writeFile(): no need of handling FileNotFoundException there, because no code throwing this checked exception.
2) okUsername(): should return boolean value. Method should have a default return type irrespective of the return statement which is there in condition scope.
Thanks,
Rajasekar.
Greg Brannon
Bartender
Joined: Oct 24, 2010
Posts: 530
posted
0
Please, please, please post your code in code tags.
I believe the problem with your okUserName() method is that you have a return statement in an if clause (or in if clauses). When the compiler sees this, it assumes it is possible that the if clauses will never be executed so that a return may never occur, causing the error, method x() must return <something>. A way to correct this is with an else statement:
That way the compiler will see there will always be a value returned.
Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.