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!

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;
}

Well, a lot of good it did to ask the OP those questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.