level 1
创建Integer类对象,并以int类型将Integer的值返回
public class Integer {public static void main(String args[]){Integer in=new Integer("456");System.out.println(in.intValue);}}这是我自己的理解写的,但不能通过编译,求解释
2011年06月25日 02点06分
1
level 1
这个当然不能了
public class Integer{
public static void main(String args[]){
Integer in=new Integer("456");
System.out.println(in);
}
}
就行了 我没有看懂你的创建I类对象啥意思 是创建integer的对象 还是创建对象
2011年06月25日 03点06分
2
level 1
这个问题解决了,我忘记了Integer本身是一个类,不能做类名,改一下就可以了,以下的修改了的并且可以运行的代码
public class no1 {
public static void main(String arge[]){
Integer in=new Integer("666");
System.out.println(in.intValue());
}}
2011年06月25日 08点06分
3
level 1
intValue()就是一个返回值为int类型的方法
2011年06月25日 08点06分
4
level 1
类名一般用大写开头,虽然不是强制规定,还是符合规范比较好
2011年06月25日 08点06分
5
level 1
对,这点没有注意好,养成良好习惯对将来是有好处的,新人啊,请多多指点
2011年06月25日 09点06分
6
level 1
public class Integer {
public static void main(String args[]){
//由于本身类名是Integer 程序会先创建最近的类 也就是自己
//而不是你自己想要的java.中的Integer类
Integer in=new Integer("456");
System.out.println(in.intValue);
}
}
看了回帖是种美德
2011年06月25日 13点06分
8