0
class MOrders
{
int nooforders; // Data members of the class
public int getorder()
{
nooforders = 500;
}
public void displayorders()
{
System.out.println("The number of orders to be delivered: "+ nooforders);
}
public static void main(String args[])
{
MOrders obj = new MOrders ();
obj.getorder();
obj.displayorders();
}

getting a statement saying missing return statement on line 6,while trying to compile the code.so can someone please help me!

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by masijade
1

What does the method signature

public int getorder()

mean? And does the method actually fulfill that contract?

-1
class MOrders
{
int nooforders; // Data members of the class
public int getorder()
{
nooforders = 500;
}
public void displayorders()
{
System.out.println("The number of orders to be delivered: "+ nooforders);
}
public static void main(String args[])
{
MOrders obj = new MOrders ();
obj.getorder();
obj.displayorders();
}

getting a statement saying missing return statement on line 6,while trying to compile the code.so can someone please help me!

You have declared the method getOrder() to have a return type of type integer. You currently aren't returning anything therefore you get the error. Try returning the value like this:

public int getorder()
{
nooforders = 500;
return nooforders;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.