jdk1.5免費版下載 最新軟件(jiàn)|熱門排行(háng)|軟件分類|軟件(jiàn)專題|廠商大全

您的位置: 首頁編程開發編程工(gōng)具 → jdk1.5.0 官方綠色版

jdk1.5.0

官方(fāng)綠色版 jdk1.5.0 網友評分:8

同類相關軟件(jiàn)

軟件(jiàn)介紹

軟(ruǎn)件標簽: jdk

jdk1.5.0是一款(kuǎn)JAVA最原始的軟件開發(fā)工具包,Java JDK是JAVA運(yùn)行的(de)核心,一些開發的應用都(dōu)需要安裝Java JDK環境(jìng)的應用軟件。趕快下載吧!!!

JDK1.5.0的11個主要新特征

自動實(shí)現裝箱和解箱操作(Boxing/Unboxing Conversions)

說明(míng):實現了基本類(lèi)型與(yǔ)外覆類之間的隱(yǐn)式轉換。基本類型至外覆類的轉換稱(chēng)為裝箱,外覆類至基本類型(xíng)的轉換為解箱。這些類包括

Primitive Type     Reference Type

boolean           Boolean

byte              Byte

char              Character

short             Short

int               Integer

long              Long

float              Float

double            Double

例如,舊的實現方式

Integer intObject;

int intPrimitive;

ArrayList arrayList = new ArrayList();

intPrimitive = 11;

intObject = new Integer(intPrimitive);

arrayList.put(intObject); // 不(bú)能放入int類型,隻能使Integer

新的實現方式(shì)

int intPrimitive;

ArrayList arrayList = new ArrayList();

intPrimitive = 11;

//在這裏(lǐ)intPrimitive被自動(dòng)的轉換(huàn)為Integer類型(xíng)

arrayList.put(intPrimitive);

5靜態(tài)導入(Static Imports)

很簡單的東西,看一個例子:

沒有靜態導入

Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

有了靜態導入

import static java.lang.Math.*;

sqrt(pow(x, 2) + pow(y, 2));

其中import static java.lang.Math.*;就是靜態導入的語法,它(tā)的意思是導(dǎo)入Math類(lèi)中的所有static方法和屬性(xìng)。這樣(yàng)我們在使用這些方法和屬性(xìng)時就不必寫類名。

需要(yào)注意的是(shì)默認包無法(fǎ)用靜態導入,另外如果導入的類中有重複的方法和屬性則需要寫出類名,否則編譯時無法通過。

6枚舉類(Enumeration Classes)

用法:public enum Name {types, ….}

簡單的(de)例子:

public enum Colors {Red, Yellow, Blue, Orange, Green, Purple, Brown, Black}

public static void main(String[] args){

Colors myColor = Colors.Red;

System.out.println(myColor);

}

又一個(gè)簡單例子:

import java.util.*;

enum OperatingSystems {windows, unix, linux, macintosh}

public class EnumExample1 {

public static void main(String args[])  {

OperatingSystems os;

os = OperatingSystems.windows;

switch(os) {

case windows:

System.out.println(“You chose Windows!”);

break;

case unix:

System.out.println(“You chose Unix!”);

break;

case linux:

System.out.println(“You chose Linux!”);

break;

case macintosh:

System.out.println(“You chose Macintosh!”);

break;

default:

System.out.println(“I don’t know your OS.”);

break;

}

}

}

應(yīng)運enum簡寫的例子:

import java.util.*;

public class EnumTest

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.print("Enter a size: (SMALL, MEDIUM, LARGE, EXTRA_LARGE) ");

String input = in.next().toUpperCase();

Size size = Enum.valueOf(Size.class, input);

System.out.println("size=" + size);

System.out.println("abbreviation=" + size.getAbbreviation());

if (size == Size.EXTRA_LARGE)

System.out.println("Good job--you paid attention to the _.");

}

}

enum Size

{

SMALL("S"), MEDIUM("M"), LARGE("L"), EXTRA_LARGE("XL");

private Size(String abbreviation) { this.abbreviation = abbreviation; }

public String getAbbreviation() { return abbreviation; }

private String abbreviation;

}

enum類中擁(yōng)有方法的一個例子:

enum ProgramFlags {

showErrors(0x01),

includeFileOutput(0x02),

useAlternateProcessor(0x04);

private int bit;

ProgramFlags(int bitNumber) {

bit = bitNumber;

}

public int getBitNumber()   {

return(bit);

}

}

public class EnumBitmapExample {

public static void main(String args[])  {

ProgramFlags flag = ProgramFlags.showErrors;

System.out.println(“Flag selected is: “ +

flag.ordinal() +

“ which is “ +

flag.name());

}

}

7元數(shù)據(Meta data)

請參考

http://www-900.ibm.com/developerWorks/cn/java/j-annotate1/

http://www-900.ibm.com/developerworks/cn/java/j-annotate2.shtml

8Building Strings(StringBuilder類)

在JDK5.0中引入了StringBuilder類,該類的(de)方法不(bú)是(shì)同步(synchronized)的,這使(shǐ)得它比(bǐ)StringBuffer更加輕量級(jí)和有(yǒu)效。

9控製台輸入(Console Input)

在JDK5.0之(zhī)前我們隻能通過JOptionPane.showInputDialog進行輸入,但在5.0中我們可以通過類Scanner在控製台進行輸入操作

例如(rú)在1.4中的輸入

String input = JOptionPane.showInputDialog(prompt);

int n = Integer.parseInt(input);

double x = Double.parseDouble(input);

s = input;

在5.0中我們可以

Scanner in = new Scanner(System.in);

System.out.print(prompt);

int n = in.nextInt();

double x = in.nextDouble();

String s = in.nextLine();

10Covariant Return Types(不曉得怎麽翻譯,大概是 改變返回類型(xíng))

JDK5之前我們覆蓋一個(gè)方法時我們無法改變被方法的返回類型,但在JDK5中我們可以改變它

例如1.4中我們隻能

public Object clone() { ... }

...

Employee cloned = (Employee) e.clone();

但是在5.0中我們可(kě)以(yǐ)改變返回類型為Employee

public Employee clone() { ... }

...

Employee cloned = e.clone();

11格式化I/O(Formatted I/O)

增加了(le)類似C的格式化輸入輸出,簡(jiǎn)單的例子:

public class TestFormat{

public static void main(String[] args){

int a = 150000, b = 10;

float c = 5.0101f, d = 3.14f;

System.out.printf("%4d %4d%n", a, b);

System.out.printf("%x %x%n", a, b);

System.out.printf("%3.2f %1.1f%n", c, d);

System.out.printf("%1.3e %1.3e%n", c, d*100);

}

}

輸出(chū)結果為:

150000   10

249f0 a

5.01 3.1

5.010e+00 3.140e+02

軟件截圖

下載地址 電腦版

點擊報錯 軟件無法下載或下載後無法使用(yòng),請點擊報錯,謝謝!

用戶評論

熱門評論

最新評論

發表評論 查看所有評論(0)

昵稱:
請不要評(píng)論無意義或髒話,我們所有評論會有人工審(shěn)核(hé).
字數: 0/500 (您的(de)評(píng)論需要經過審核才能顯示)
免费人欧美成又黄又爽的视频丨一本色道久久88综合日韩精品丨国产专区日韩精品欧美色丨午夜无遮挡男女啪啪视频丨国产欧美日韩综合精品一区二区丨亚洲精品无码不卡在线播HE丨亚洲精品国产精品国自产观看丨日韩国产高清av不卡