Scanner工具类的初始化问题,求大神
//父类
package text2;
public class vehicle {
public void transport(){
System.out.println("交通工具具有运输的能力");
}
public int site;//载客数
public String transMode;//运送方式
public void operation(){
}
}
//子类
package text2;
public class car extends vehicle {
int site=1;
String transMode="land";
public void operation(){
System.out.println("汽车可载客"+site+"人,运送方式为"+transMode);
}
}
//子类
package text2;
public class plane extends vehicle {
int site=150;
String transMode="fly";
public void operation(){
System.out.println("飞机可载客"+site+"人,运送方式为"+transMode);
}
}
//子类
package text2;
public class train extends vehicle {
int site=1500;
String transMode="land";
public void operation(){
System.out.println("火车可载客"+site+"人,运送方式为"+transMode);
}
}
//方法
package text2;
import java.util.Scanner;
public class inital {
public static void main(String[] args) {
// TODO Auto-generated method stub
vehicle car=new car();
vehicle plane=new plane();
vehicle train=new train();
Scanner input =new Scanner(System.in);
System.out.println("请输入查询的对象:");
String Name=input.next();
String a="plane";
String b="train";
String c="car";
if(Name.equals(a)){
plane.operation();
}else if(Name.equals(b)){
train.operation();
}else if(Name.equals(c)){
car.operation();
}else{
System.out.println("!请检查输入的对象名称");
}
input.close();
}
}
问题就是每次执行的时候只能查询一次,输错了回车执行之后也不能重新输入,怎么样可以多次查询啊