Re: Gibberish output is display when returning an array
From: Jose Rubio (spam_at_airphoria.com)
Date: 11/29/03
- Next message: Anthony Borla: "Re: Storing classes in a RandomAccessFile"
- Previous message: VisionSet: "Re: Gibberish output is display when returning an array"
- In reply to: Mohammed Mazid: "Gibberish output is display when returning an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Nov 2003 00:52:07 GMT
See below...
"Mohammed Mazid" <kadmazid@hotmail.com> wrote in message
news:7cfd7b4a.0311281428.2e20f8b5@posting.google.com...
> I changed my code as I initially used an Object arrays, I decided to
> use String array instead as I can convert from a date/time to a
> string.
>
> However, when I compiled and run, it displayed a nonsense output.
> Something in the nature of "java.lang.String@28934".
This is not nonsense. That's how Java displays an object.
>
> Here is my latest code fragment.
>
> //This will be passed to the method displayFlights
> String flight1 = "BA123";
>
> String flightArray[] = new String[6];
>
> for (int i = 0; i < flightArray.length; i++)
> {
> out.println("<td>" );
> out.println(displayFlight(flight1));
You're displaying an array, not the actual flight for the first element of
the array. That's why you see the nonsense you called above.
Accoridng to the method below, change the loop above to:
String flightArray[] = displayFlight( flight1 );
for(int i=0; i < flightArray.length; i++ )
{
out.println( "<td">);
out.println( flightArray[ i ] );
out.println( "</td>" );
}
> out.println("</td>" );
> out.println("<br>");
> }
> }
>
> // Return an array of flight details
> public String[] displayFlight(String flightNo)
> {
> String[] flight = new String[6];
> SetupFlightDB flightDB = new SetupFlightDB();
> FlightInformation flightInfo = flightDB.flightDetails(flightNo);
>
> flight[0] = flightInfo.getFlightNo();
>
> java.sql.Date flightDate = flightInfo.getFlightDate();
> String dateString = String.valueOf(flightDate);
> flight[1] = dateString;
>
> flight[2] = flightInfo.getDestination();
>
> java.sql.Time depTime = flightInfo.getDepTime();
> String dTimeString = String.valueOf(depTime);
> flight[3] = dTimeString;
>
> java.sql.Time arrTime = flightInfo.getArrTime();
> String aTimeString = String.valueOf(arrTime);
> flight[4] = aTimeString;
>
> flight[5] = flightInfo.getAirline();
> return flight;
> }
>
> Basically I am trying to achieve something like this - pass a string
> to the method so that from a DB table, it displays all the records
> from the columns in an array style.
>
> Can anyone suggest me some improvement to the above.
>
> Thank you.
Hope it helps.
-- Jose Rubio Lead Consultant Airphoria http://www.airphoria.com
- Next message: Anthony Borla: "Re: Storing classes in a RandomAccessFile"
- Previous message: VisionSet: "Re: Gibberish output is display when returning an array"
- In reply to: Mohammed Mazid: "Gibberish output is display when returning an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|