gpt4 book ai didi

java - 错误表达式 11111 的非法开始

转载 作者:行者123 更新时间:2023-12-01 08:00:51 25 4
gpt4 key购买 nike

下面是不断提示表达式非法开始的代码:

 public static conversionRate= 4.546;

完整代码如下:

/**
* Write a description of class VolumeConversion here.
*

* @author (Aneeqa Rustam)
* @version (07/08/2014)
*/

public class VolumeConversion
{

// instance variables - replace the example below with your own


/**
* Constructor for objects of class VolumeConversion
*/
public VolumeConversion()
{
public static conversionRate= 4.546;

znaslcmlkmlskm(String[]args)

//Declare the variable and constants

double litres= 0;
double gallon= 14;

//Perform the conversion calculation

litres= gallon* conversionRate;

//This is the output result that is going to be shown to the user

System.out.println("The number of litres in "+gallons+ "gallons is" +litres);

}
}

最佳答案

您需要变量的类型。例如:

public static float conversionRate = 4.546f;

您还希望将其作为类级别变量放置在构造函数之外。

关于java - 错误表达式 11111 的非法开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25334067/

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