Java 中的所有处理都放在了对象当中,那么我想知道int 是相当于类的什么数据成员??
解决方案 »
- 请教高手!~关于JFrame组件更新(有代码)
- 哪位高人能帮我解释一下关于地址和引用传递的问题?800里加急,在线等待回复!(用分砸死你)
- 怎么对已存在的XML文档进行修改
- 考研放分啦
- 如何为Image对象创建一个inputStream!!!在线求答,给分。
- 如何从ImageIcon获取BufferedImage
- 有关jtable的问题。请指教。
- 请教:如何用Java实现压缩功能?
- 这样的功能,java能实现吗?
- java 如何统计名字出现次数
- 页面的加了这个上传的enctype="multipart/form-data,怎么取字段的数组值,不能request.getParameterValues(""),急!!!
- 关于流与其他类型的转化
Integer是int的封装类,里面有很多进行处理的静态方法
Integer是对象而int不是,内存的分配位置也不一样
Float 类的一个成员函数....
float floatValue()
返回这个 Float 对象的 float 值。
Integer 是类java.lang.Integer
也就是说Integer i == null可以
但是int i == null就不可以
INGER是一个类所以在类INTER会有很多的方法及属性,但INT没有
-----------------------------------
int是一种基本数据类型,而Integer是相应于int的类类型,称为对象包装。
实现这种对象包装的目的主要是因为类能够提供必要的方法,用于实现基本数据类型的数值与可打印字符串之间的转换,以及一些其他的实用程序方法;
另外,有些数据结构库类只能操作对象,而不支持基本数据类型的变量,包装类提供一种便利的方式,能够把基本数据类型转换成等价的对象,从而可以利用数据结构库类进行处理。
int: 数字类型
Integer: 数字类数字类型int可以直接进行加、减、乘、除运算操作,数字类Integer不可以。
数字类Integer拥有自己的属性与方法,数字类型int本身不存在属性与方法。
Integer是对象类我想知道既然有了Integer那么还要int这种基本数据类型是什么原因??
-----------------------------------向上兼容
Newbies are often confused by the difference between int and Integer.
To properly understand the difference, you should read an introductory textbook on Java. I will make a small stab at answering here. Everything I say here applies analogously to char and Character, short and Short, long and Long, float and Float, double and Double. Definitions
An int is a primitive. It is not an Object. An int is a high performance, streamlined beast for calculating numbers in the range -2,147,483,648 [-231] aka Integer.MIN_VALUE to +2,147,483,647 [2 31-1] aka Integer.MAX_VALUE. An int is a bare bones 32-bit chunk of information. int variables are mutable. Unless you them final, you can change their value at any time.
An Integer, is a Object that contains a single int field. An Integer is much bulkier than an int. It is sort like a Fedex box to contain the int. Integers are immutable. If you want to affect the value of a Integer variable, the only way is to create a new Integer object and discard the old one.
INGER是一个类所以在类INTER会有很多的方法及属性,但INT没有
====================================这个回复强~
/**
* A constant holding the minimum value an <code>int</code> can
* have, -2<sup>31</sup>.
*/
public static final int MIN_VALUE = 0x80000000; /**
* A constant holding the maximum value an <code>int</code> can
* have, 2<sup>31</sup>-1.
*/
public static final int MAX_VALUE = 0x7fffffff; /**
* The <code>Class</code> instance representing the primitive type
* <code>int</code>.
*
* @since JDK1.1
*/
public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int"); /**
* All possible chars for representing a number as a String
*/
final static char[] digits = {
'0' , '1' , '2' , '3' , '4' , '5' ,
'6' , '7' , '8' , '9' , 'a' , 'b' ,
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
};在你的C:\Program Files\Java\jdk1.5.0下面有一个src的压缩包里面有java的源文件你可以自己研究研究
它里面不是处处是对象
因为它的数据类型除了类和接口等引用数据类型外
还包含了面向过程的基本数据类型
只是为了让广大程序员学习者容易接受
互相学习 互相提高