import java.util.Scanner;
public class Tutorials {
public static void main(String[] args) {
Car Vehicle = new Car();
Vehicle.supboys();
}
}
import java.util.Scanner;
public class Car {
private String Vehicle;
public Car(String name) {
Vehicle=name;
}
Car() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setName (String name) {
Vehicle=name;
}
public String getName (){
return Vehicle;
}
public void saying(){
System.out.printf("Vehicle Brand is called %s\n ", getName());
}
public void supboys() {
Scanner Boyz = new Scanner(System.in);
System.out.println ("Your New Car is " + Boyz);
}
}
我是编程新手,所以我想对构造函数进行一些练习。我想尝试为此程序做一个扫描仪类,但似乎无法使其正常工作。该程序也没有给我正确的错误消息。有没有人有什么建议? (为乱码表示歉意)
您需要使用扫描仪的方法来使扫描仪以所需的方式工作。您可能想做这样的事情:
Scanner Boyz = new Scanner(System.in);
String shoutout = Boyz.nextLine();
System.out.println ("Your New Car is " + shoutout);