在线等怎么把Char c='9',转换成整型数9.为什么我import java.math.*,还是不能识别round这样的函数? 问题一:Integer.parseint(c)问题二:import java.lang.math 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Char c='9'Integer.valueOf(c.intValue()); 1.Integer.parseInt(c.toString());2.round()是Math类的方法:import java.lang.Math;........Math.round(....);...... 现在是String string="123",怎么把它转换成整数123啊? 不好意思,弄错了。char是基类型,没有toString()方法。(Character才有)应该是:char c='9'; //注意不是CharInteger.parseInt(String.valueOf(c)); 更好办了,String string="123";int i = Integer.parseInt(string); 整数:String strTmp="123";int intTmp=0;intTmp=Integer.parseInt(strTmp);System.out.print(intTmp);float、double型:String strTmp='12345.6789';float fltTmp=0.0;fltTmp=Float.parseFloat(strTmp);类似......dblTmp=Double.parseDouble(strTmp);...lngTmp=Double.parseLong(strTmp)还可以有另外一种方法,先把字符转成类,再由类进行转换如:String strTmp="123.456"; Double dblClassTmp=new Double(strTmp); //注意这个Double是对象,不是基本类型了 int intTmp=0; float fltTmp=0.0; long lngTmp=0; intTmp=dblClassTmp.intValue(); //123 fltTmp=dblClassTmp.floatValue(); //123 lngTmp=dblClassTmp.longValue(); //123.456 round是Math类的一个静态函数。 上面错误校正:类似......dblTmp=Double.parseDouble(strTmp);...lngTmp=long.parseLong(strTmp); 不用写 import java.lang.Math; 语句,java.lang包是自动导入的 第一个问题:int i=Integer.parseInt(c+"");第二个问题:round()是Math类的静态方法:static int round(float arg) 和 staic long round(double arg)import java.lang.Math;int i=Math.round(...); 急!!! JAVA图形界面问题 JAVA 文件重命名失败 崩溃啦。。。救命啊。。。关于Image中DrawString 关于ajax的问题 刚学java,这段程序看不懂 这是java未公开的写法么? 程序员年龄调查,及今后的发展方向。 两个HelloJava的问题,很菜,不要笑我 请问:哪儿可以下载到 Visual J++ 6.0 ?着急啊!!~! 如何监听鼠标双击事件? 讨论: interface 和 abstract class的使用目的是什么?
Integer.valueOf(c.intValue());
2.round()是Math类的方法:
import java.lang.Math;
....
....Math.round(....);
......
char是基类型,没有toString()方法。(Character才有)
应该是:
char c='9'; //注意不是Char
Integer.parseInt(String.valueOf(c));
String string="123";
int i = Integer.parseInt(string);
String strTmp="123";
int intTmp=0;
intTmp=Integer.parseInt(strTmp);
System.out.print(intTmp);float、double型:
String strTmp='12345.6789';
float fltTmp=0.0;
fltTmp=Float.parseFloat(strTmp);
类似...
...dblTmp=Double.parseDouble(strTmp);
...lngTmp=Double.parseLong(strTmp)还可以有另外一种方法,先把字符转成类,再由类进行转换
如:String strTmp="123.456";
Double dblClassTmp=new Double(strTmp); //注意这个Double是对象,不是基本类型了
int intTmp=0; float fltTmp=0.0; long lngTmp=0;
intTmp=dblClassTmp.intValue(); //123
fltTmp=dblClassTmp.floatValue(); //123
lngTmp=dblClassTmp.longValue(); //123.456
类似...
...dblTmp=Double.parseDouble(strTmp);
...lngTmp=long.parseLong(strTmp);
static int round(float arg) 和 staic long round(double arg)import java.lang.Math;
int i=Math.round(...);