gpt4 book ai didi

java - 缺少返回语句错误,我不知道错误是什么

转载 作者:行者123 更新时间:2023-11-29 09:46:22 24 4
gpt4 key购买 nike

这是代码,

class Car
{
public static String owner;
public static String car;
public static Integer plate_num;
public static String car_color;

Car(String owner, String car_name, Integer num, String color)
{
owner = owner;
car = car_name;
plate_num = num;
car_color = color;
}

Void display ()
{
System.out.println("The owner of the car is "+ owner + "and Car model is " + car);

System.out.println("The car number is "+ plate_num + "and Car color is " + car_color);
} // ---> here is the error

public static void main (String args[])
{
Car car1 = new Car("MAriam", "Mini Cooper", 124834, "Navey");

car1.display() ;

//System.out.println("Y3es");
}
}

最佳答案

这里有一个 Void 返回值。 Void 实际上是一个类。

要解决您的问题,您必须将其更改为小写的 void


资源:

关于java - 缺少返回语句错误,我不知道错误是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3749084/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com