Hi ranchers,
I have a class:
class Hotel{
String hotelName;
}
and in another class I produce Hotel objects:
class ConnectDB {
public static Hotel[] getHotel(){
}
}
and now is my question,
class Data{
private Hotel[] hotels = ConnectDB.getHotel();
}
in Data I have the main method,in main i have a sentence :
Data da = new Data();
System.out.print(da.hotels[8].hotelName);
so Data.java compile fine, but while i run it,there is exception of java.lang.StringIndexOutOfBoundsException .
Why?Can anyone help me ?