java.lang 類 Integerjava.lang.Object java.lang.Number java.lang.Integer所有已實(shí)現(xiàn)的接口: Serializable, Comparable --------------------------------------------------------------------------------public final class Integerextends Numberimplements ComparableInteger 類在對(duì)象中包裝了一個(gè)基本類型 int 的值。
Integer 類型的對(duì)象包含一個(gè) int 類型的字段。 此外,該類提供了多個(gè)方法,能在 int 類型和 String 類型之間互相轉(zhuǎn)換,還提供了處理 int 類型時(shí)非常有用的其他一些常量和方法。
實(shí)現(xiàn)注意事項(xiàng):“bit twiddling”方法(如 highestOneBit 和 numberOfTrailingZeros)的實(shí)現(xiàn)基于 Henry S. Warren, Jr.撰寫的《Hacker's Delight》(Addison Wesley, 2002)中的一些有關(guān)材料。 從以下版本開始: JDK1.0 另請(qǐng)參見:序列化表格--------------------------------------------------------------------------------字段摘要 static int MAX_VALUE 保持 int 類型的最大值的常量可取的值為 231-1。
static int MIN_VALUE 保持 int 類型的最小值的常量可取的值為 -231。 static int SIZE 以二進(jìn)制補(bǔ)碼形式表示 int 值的位數(shù)。
static Class TYPE 表示基本類型 int 的 Class 實(shí)例。 構(gòu)造方法摘要 Integer(int value) 構(gòu)造一個(gè)新分配的 Integer 對(duì)象,它表示指定的 int 值。
Integer(String s) 構(gòu)造一個(gè)新分配的 Integer 對(duì)象,它表示 String 參數(shù)所指示的 int 值。 方法摘要 static int bitCount(int i) 返回指定 int 值的二進(jìn)制補(bǔ)碼表示形式的 1 位的數(shù)量。
byte byteValue() 以 byte 類型返回該 Integer 的值。 int compareTo(Integer anotherInteger) 在數(shù)字上比較兩個(gè) Integer 對(duì)象。
static Integer decode(String nm) 將 String 解碼為 Integer。 double doubleValue() 以 double 類型返回該 Integer 的值。
boolean equals(Object obj) 比較此對(duì)象與指定對(duì)象。 float floatValue() 以 float 類型返回該 Integer 的值。
static Integer getInteger(String nm) 確定具有指定名稱的系統(tǒng)屬性的整數(shù)值。 static Integer getInteger(String nm, int val) 確定具有指定名稱的系統(tǒng)屬性的整數(shù)值。
static Integer getInteger(String nm, Integer val) 返回具有指定名稱的系統(tǒng)屬性的整數(shù)值。 int hashCode() 返回此 Integer 的哈希碼。
static int highestOneBit(int i) 返回具有至多單個(gè) 1 位的 int 值,在指定的 int 值中最高位(最左邊)的 1 位的位置。 int intValue() 以 int 類型返回該 Integer 的值。
long longValue() 以 long 類型返回該 Integer 的值。 static int lowestOneBit(int i) 返回具有至多單個(gè) 1 位的 int 值,在指定的 int 值中最低位(最右邊)的 1 位的位置。
static int numberOfLeadingZeros(int i) 在指定 int 值的二進(jìn)制補(bǔ)碼表示形式中最高位(最左邊)的 1 位之前,返回零位的數(shù)量。 static int numberOfTrailingZeros(int i) 返回指定的 int 值的二進(jìn)制補(bǔ)碼表示形式中最低(“最右”)的為 1 的位后面的零位個(gè)數(shù)。
static int parseInt(String s) 將字符串參數(shù)作為有符號(hào)的十進(jìn)制整數(shù)進(jìn)行分析。 static int parseInt(String s, int radix) 使用第二個(gè)參數(shù)指定的基數(shù),將字符串參數(shù)解析為有符號(hào)的整數(shù)。
static int reverse(int i) 返回通過反轉(zhuǎn)指定 int 值的二進(jìn)制補(bǔ)碼表示形式中位的順序而獲得的值。 static int reverseBytes(int i) 返回通過反轉(zhuǎn)指定 int 值的二進(jìn)制補(bǔ)碼表示形式中字節(jié)的順序而獲得的值。
static int rotateLeft(int i, int distance) 返回根據(jù)指定的位數(shù)循環(huán)左移指定的 int 值的二進(jìn)制補(bǔ)碼表示形式而得到的值。 static int rotateRight(int i, int distance) 返回根據(jù)指定的位數(shù)循環(huán)右移指定的 int 值的二進(jìn)制補(bǔ)碼表示形式而得到的值。
short shortValue() 以 short 類型返回該 Integer 的值。 static int signum(int i) 返回指定 int 值的符號(hào)函數(shù)。
static String toBinaryString(int i) 以二進(jìn)制(基數(shù) 2)無符號(hào)整數(shù)形式返回一個(gè)整數(shù)參數(shù)的字符串表示形式。 static String toHexString(int i) 以十六進(jìn)制的無符號(hào)整數(shù)形式返回一個(gè)整數(shù)參數(shù)的字符串表示形式。
static String toOctalString(int i) 以八進(jìn)制(基數(shù) 8)無符號(hào)整數(shù)形式返回一個(gè)整數(shù)參數(shù)的字符串表示形式。 String toString() 返回一個(gè)表示該 Integer 值的 String 對(duì)象。
static String toString(int i) 返回一個(gè)表示指定整數(shù)的 String 對(duì)象。 static String toString(int i, int radix) 用第二個(gè)參數(shù)指定的基數(shù)返回第一個(gè)參數(shù)的字符串表示形式。
static Integer valueOf(int i) 返回一個(gè)表示指定的 int 值的 Integer 實(shí)例。 static Integer valueOf(String s) 返回保持指定的 String 的值的 Integer 對(duì)象。
static Integer valueOf(String s, int radix) 返回一個(gè) Integer 對(duì)象,該對(duì)象中保持了用第二個(gè)參數(shù)提供的基數(shù)進(jìn)行分析時(shí)從指定的 String 中提取的值。 從類 java.lang.Object 繼承的方法 clone, finalize, getClass, notify, notifyAll, wait, wait, wait。
java基本數(shù)據(jù)類型就8種,記住就好了。除了這些都是引用型的了。
java四類八種基本數(shù)據(jù)類型
第一類:整型 byte short int long
第二類:浮點(diǎn)型 float double
第三類:邏輯型 boolean(它只有兩個(gè)值可取true false)
第四類:字符型 char
基本數(shù)據(jù)類型自動(dòng)轉(zhuǎn)換
byte->short,
char ->int ->long
float ->double
int ->float
long ->double
其他的,你看到的是常用的類,如String StringBuffer ArrayList HashMap Date 。。
海楓科技
JAVA 中int類型轉(zhuǎn)String類型的通常方法,有三種:1、String.valueOf(int i)2、Integer.toString(int i)3、i+""; //i 為 int類型是string類型的字符串跟上個(gè)int類型的i代表的字符串(先把i轉(zhuǎn)換為string),int+string型就是先將int型的i轉(zhuǎn)為string然后跟上后面的string。
三種方法效率排序?yàn)椋篒nteger.toString(int i) > String.valueOf(int i) > i+"";。
直接調(diào)用java api里面的方法:
static int MAX_VALUE
保持 int 類型的最大值的常量可取的值為 231-1。
static int MIN_VALUE
保持 int 類型的最小值的常量可取的值為 -231。
static int SIZE
以二進(jìn)制補(bǔ)碼形式表示 int 值的位數(shù)。
static Class<Integer> TYPE
表示基本類型 int 的 Class 實(shí)例。
聲明:本網(wǎng)站尊重并保護(hù)知識(shí)產(chǎn)權(quán),根據(jù)《信息網(wǎng)絡(luò)傳播權(quán)保護(hù)條例》,如果我們轉(zhuǎn)載的作品侵犯了您的權(quán)利,請(qǐng)?jiān)谝粋€(gè)月內(nèi)通知我們,我們會(huì)及時(shí)刪除。
蜀ICP備2020033479號(hào)-4 Copyright ? 2016 學(xué)習(xí)鳥. 頁面生成時(shí)間:2.952秒