M
Mohammed Mazid
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".
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));
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.
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".
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));
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.