Click here to Skip to main content
15,890,932 members
Home / Discussions / Java
   

Java

 
AnswerRe: key word 'this' Pin
Neo101011-Oct-10 12:45
Neo101011-Oct-10 12:45 
AnswerRe: key word 'this' Pin
Dave Doknjas2-Oct-10 13:31
Dave Doknjas2-Oct-10 13:31 
AnswerRe: key word 'this' Pin
jwintermute5-Oct-10 5:11
jwintermute5-Oct-10 5:11 
AnswerRe: key word 'this' Pin
RaviRanjanKr8-Nov-10 17:51
professionalRaviRanjanKr8-Nov-10 17:51 
Questionprinting jtextpane silently Pin
ndiga29-Sep-10 22:58
ndiga29-Sep-10 22:58 
AnswerRe: printing jtextpane silently Pin
TorstenH.5-Oct-10 3:13
TorstenH.5-Oct-10 3:13 
Questionprinting multiple items on the same paper Pin
ndiga29-Sep-10 22:56
ndiga29-Sep-10 22:56 
Question"missing return statement" error [Solved] Pin
Skippums29-Sep-10 8:33
Skippums29-Sep-10 8:33 
I have a function that is similar to the following:
public int LoadFromFile(String fileName) {
    FileReader reader = null;
    try {
        int rval = 0;
        reader = new FileReader(fileName);
        // Do some stuff to get 'rval' from the file
        return rval;
    } finally {
        if (reader != null) reader.close();
    }
}
I don't understand why I am getting the compile-time error, "missing return statement". Either execution gets to the line "return rval;", or an exception is thrown and no value needs to be returned. I can get the compile-time error to go away if I move the return value declaration prior to the try block and move the return statement after the finally block (I read online that putting a return statement within the finally block suppresses all exceptions), but I don't understand why I need to do that. Thanks for any help,
Sounds like somebody's got a case of the Mondays

-Jeff

AnswerRe: "missing return statement" error Pin
Skippums29-Sep-10 9:25
Skippums29-Sep-10 9:25 
AnswerRe: "missing return statement" error Pin
Luc Pattyn29-Sep-10 10:06
sitebuilderLuc Pattyn29-Sep-10 10:06 
QuestionXml beans problem Pin
Stephen Lintott29-Sep-10 5:10
Stephen Lintott29-Sep-10 5:10 
QuestionImmutability compromised if 'final' is omitted? Pin
Neo1010127-Sep-10 7:50
Neo1010127-Sep-10 7:50 
AnswerRe: Immutability compromised if 'final' is omitted? Pin
DaveAuld27-Sep-10 8:37
professionalDaveAuld27-Sep-10 8:37 
AnswerRe: Immutability compromised if 'final' is omitted? Pin
DaveAuld27-Sep-10 9:47
professionalDaveAuld27-Sep-10 9:47 
AnswerRe: Immutability compromised if 'final' is omitted? Pin
Nagy Vilmos29-Sep-10 1:21
professionalNagy Vilmos29-Sep-10 1:21 
QuestionConflicts with a scope too wide? Pin
Neo1010127-Sep-10 7:48
Neo1010127-Sep-10 7:48 
AnswerRe: Conflicts with a scope too wide? Pin
TorstenH.28-Sep-10 0:04
TorstenH.28-Sep-10 0:04 
GeneralRe: Conflicts with a scope too wide? Pin
David Skelly28-Sep-10 0:18
David Skelly28-Sep-10 0:18 
GeneralRe: Conflicts with a scope too wide? Pin
TorstenH.28-Sep-10 0:35
TorstenH.28-Sep-10 0:35 
QuestionA Collection is not thread-safe? Pin
Neo1010127-Sep-10 7:44
Neo1010127-Sep-10 7:44 
AnswerRe: A Collection is not thread-safe? Pin
Richard MacCutchan27-Sep-10 22:03
mveRichard MacCutchan27-Sep-10 22:03 
GeneralRe: A Collection is not thread-safe? Pin
Branislav Vidovic28-Sep-10 20:58
Branislav Vidovic28-Sep-10 20:58 
GeneralRe: A Collection is not thread-safe? Pin
Richard MacCutchan28-Sep-10 21:23
mveRichard MacCutchan28-Sep-10 21:23 
QuestionThreads and UML Pin
Neo1010127-Sep-10 6:27
Neo1010127-Sep-10 6:27 
AnswerRe: Threads and UML Pin
DaveAuld27-Sep-10 9:57
professionalDaveAuld27-Sep-10 9:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.