谁能告诉我为什么我在以下代码中收到错误消息:
import java.text.DecimalFormat;
public class Labsheet {
public static void main(String args[])
{
double number = 1.0/3.0;
DecimalFormat number_format = new DecimalFormat(“#.##”);
System.out.println(number);
String formatted_string = number_format.format(number);
System.out.println(formatted_string);
}
}
错误发生在(“#.##”); - 标记上的语法错误,删除这些标记。 我不明白为什么这是一个错误。
最佳答案
建议你更换
“#.##”
与
"#.##"
as “
is “ and ”
which is ” 不能用来分隔字符串。
关于java - 十进制格式错误 - Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35586008/