wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Need help with small problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with small problems" Watch "Need help with small problems" New topic
Author

Need help with small problems

Don Seracino
Greenhorn

Joined: Mar 18, 2011
Posts: 1
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.
Rajasekar Krishnan
Greenhorn

Joined: Feb 27, 2008
Posts: 16

Hi Don,

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: 557
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need help with small problems
 
Similar Threads
Determining the location of the file
Reading log files from various unix servers through Java program on windows
Help with Password Checker
Boolean problem
Problem with jsp:useBean tag...URGENT