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 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

What does the method signature

public int getorder()

mean? And does the method actually fulfill that contract?

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.