www.webdeveloper.com
Results 1 to 2 of 2

Thread: Quick Method Question

  1. #1
    Join Date
    Sep 2004
    Posts
    23

    Quick Method Question

    Is this legal? Whenever i try to do this it says that there is a missing return statement.
    Thanks a lot!
    public String passengerList()
    {
    for( int a = 0; a < 12; a++ )
    {
    return( Flights.Flight1[ a ].getName() );

    } //end for loop

    for( int b = 0; b < 12; b++ )
    {
    return( Flights.Flight2[ b ].getName() );

    } //end for loop

    for( int c = 0; c < 12; c++ )
    {
    return( Flights.Flight3[ c ].getName() );

    } //end for loop

    for( int d = 0; d < 12; d++ )
    {
    return( Flights.Flight4[ d ].getName() );

    } //end for loop

    for( int e = 0; e < 12; e++ )
    {
    return( Flights.Flight5[ e ].getName() );

    } //end for loop



    } //end method passengerListReport()

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    You can only return once from a method. Once a return statement is executed the method is forgotten about and execution takes off from the calling environement.

    You actually trying to return about 60 times.

    Regards.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles