This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes This method must return a result of type String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "This method must return a result of type String" Watch "This method must return a result of type String" New topic
Author

This method must return a result of type String

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 252
Please help to fix the following error.

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
This method must return a result of type String

at ReadIniFile.getCode(ReadIniFile.java:8)
at ReadIniFile.main(ReadIniFile.java:43)

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20077
    
  30

Your code has one compiler error, and the one you mention is not it. Either you must rebuild your source, or you must PostRealCode. My guess is the former.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 252
Rob Prime wrote:Your code has one compiler error, and the one you mention is not it. Either you must rebuild your source, or you must PostRealCode. My guess is the former.


You are right!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14950
    
  26

"Unresolved compilation problem" indicates that you have multiple source files and that they are not in sync: you have class files somewhere from a previous version of the source code. The solution is to delete these old class files and recompile all the source code.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Sundeep Gupta
Greenhorn

Joined: Feb 28, 2006
Posts: 13
Also, method getCode must be static


SCJP 5.0
Mina Daoud
Ranch Hand

Joined: Sep 24, 2010
Posts: 88
The only error i can see is that method getCode should be declared static. when i changed it the code worked fine!
Mos Jeff
Greenhorn

Joined: Sep 15, 2010
Posts: 14
Sundeep Gupta wrote:Also, method getCode must be static


or In main you could create a ReadIniFile object and then make a call to the getCode method from that object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This method must return a result of type String
 
It's not a secret anymore!