Java数字1890转换为1890
要将Java中的数字1,890转换为1890,只需要去掉逗号即可。可以使用以下代码实现:
String numberWithComma = "1,890";
String numberWithoutComma = numberWithComma.replaceAll(",", "");
int number = Integer.parseInt(numberWithoutComma);
System.out.println(number); // 输出 1890
首先,我们将包含逗号的数字存储在一个字符串变量中。然后,我们使用replaceAll函数将逗号替换为空字符串,得到不包含逗号的字符串。接下来,我们使用Integer.parseInt函数将字符串转换为整数。最后,我们打印输出转换后的数字。
原文地址: http://www.cveoy.top/t/topic/iRx7 著作权归作者所有。请勿转载和采集!