I have a problem with the arrayList. this is my codes for the arrayList
I know there are some problems with my arrayList method but i cant spot it.
method for the arrayList
public ArrayList<Tour> countryList(String country)
{
ArrayList<Tour> newList = null;
switch (country)
{
case "Indonesia":
country = "IN";
break;
case "Thailand":
country = "TH";
break;
case "Singapore":
country = "SI";
break;
case "Brunei":
country = "BR";
break;
case "Philipines":
country = "PH";
break;
case "Vietnam":
country = "VI";
break;
case "Laos":
country = "LA";
break;
case "Myammmar":
country = "MY";
break;
case "Malaysia":
country = "MS";
break;
}
if(TList.indexOf(country)!= 1)
{
return newList;
}
return newList;
}
in the main class
private static void displayAllToursCountry()
{
System.out.print("Please enter the name of the country: ");
String country = sc.next();
while (country == "")
{
System.out.print("Please enter a valid country name: ");
country = sc.next();
}
System.out.println("Country:" + country);
System.out.println(ta1.countryList(country));
}
why are there no values coming out? where did i did wrongly? Thanks