No output from return statement in method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fractalyzed
    New Member
    • Nov 2012
    • 1

    No output from return statement in method

    For some reason, there is no output coming from the return statement when i run the program, i don't see what i'm doing wrong.

    Code:
    public class Supermarkets 
    {      
       
        String[] cities = { "Miami", "Sunrise", "Hollywood" , "Tallahasse" , "Jacksonville" , "Orlando" , "Gainesville" , "Pensacola" , "Ocala" , "Sebring"};   
        double[] profit = {10200000.00, 14600000.00, 17000000.00, 6000000.00, 21600000.00, 9100000.00, 8000000.00, 12500000.00, 2000000.00, 4500000.00};
       
        DecimalFormat d = new DecimalFormat();
        
        
       String display()
       {
           String s = "";
           
           for(int i = 0; i < profit.length; i++)
           {
             //System.out.println(cities[i] + " " + d.format(profit[i]));
               s = s + cities[i] + " " + profit[i] + "/n";      
           }
          return s;
           
       }
    The system.out method does give output, but the return s does nothing. In the test class i call the method through:

    Code:
    public static void main(String[] arg)
    	{
            Supermarkets beam = new Supermarkets();
            beam.display();
            }
    Any help please?
    Last edited by Rabbit; Nov 28 '12, 02:28 AM. Reason: Please use code tags when posting code.
  • Rangan
    New Member
    • Dec 2012
    • 8

    #2
    display function returned value. But you didnt print that value.
    System.out.prin tln(beam.displa y());

    Comment

    Working...