我有一个方法会返回一个字符串 [],这取决于以前的用户输入,它将确定参数是“INTERNATIONAL”还是“DOMESTIC”。无论如何,两个输入都应该导致创建两个不同的 String[]。但是,当我尝试编译时,我收到“缺少返回语句”错误消息。我怎样才能解决这个问题?
这是我的方法:
public String[] typeflight(String type)
{
String type2= type.toUpperCase();
if (type2.equals("INTERNATIONAL"))
{
String[] flights = {"B738 to Melbourne, Australia ", "A380 to Beijing, China ", "F348 to London, England ", "M225 to Ontario, Canada",
"E987 to Tokyo, Japan ", "T451 to Copenhagen, Denmark ", "S501 to Seoul, South Korea ", "N778 to Venice, Italy ",
"B621 to Mexico City, Mexico ", "L454 to Rabat, Morocco ", "C998 to San Jose, Costa Rica", "H859 to Amsterdam, Netherlands "};
return flights;
}
else
if(type2.equals("DOMESTIC"))
{
String[] flights = {"459 to Seattle, Washington ", "662 to Los Angeles, California ", "712 to New Orleans, Louisiana ", "285 to Chicago, Illinois ",
"896 to Honolulu, Hawaii ", "476 to Boston, Massachusetts ", "823 to Newark, New Jersey ", "902 to Miami, Florida ",
"353 to Fort Wayne, Indiana ", "112 to Des Moines, Iowa ", "", "294 to Las Vegas, Nevada"};
return flights;
}
}
提前致谢!