Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Java error missing return statement 
 

Java error missing return statement are those error in Java that occurred when a programmer forget to write a return statement inside the conditional clauses. method with a non-void return provides you an object of the specific type.

 

Java error missing return statement

                         

Java error missing return statement are those error in Java that occurred when a programmer forget to write a return statement inside the conditional clauses. method with a non-void return provides you an object of the specific type.

Understand with Example

In this Example we want to describe you a code that explain you  in understanding Java error missing return object. For this we have taken a non void method 'operation( )'that return you an int type and this method include a  for loop clause that check the condition If there is anything other than void method, then you must specify the return type in it. The given below code is missing a return statement in the non-void method so, whenever the compiler execute the code the code returns a missing return statement error.

There are two way to resolve this problem-

1)Change the non-void method to a void method.

2)Add or write a return expression to the non-void method.

Missingreturnstatement.java


public class Missingreturnstatement {

    public int operation(int num) {
        for (int i = 0; i <= num; i++) {
            System.out.println(i);
        }
      
    }

    public static void main(String[] args) {
        Missingreturnstatement m = new Missingreturnstatement();
        m.operation(7);
    }
}


Output

Compiling source file to /home/girish/NetBeansProjects/errors/build/classes
/home/girish/NetBeansProjects/errors/src/
Missingreturnstatement.java:
9: missing return statement

    }
error
BUILD FAILED (total time: seconds)


To resolve this error you have to give the return statement as return num;

Download code

                         

» View all related tutorials
Related Tags: c class ant help property get tutorial name ria this for to e des pe in as sta m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.