Java7

 

New Feature in Java7

  1. Strings in switch Statements
  2. Type Inference for Generic Instance Creation
  3. Multiple Exception Handling Syntax
  4. The try-with-resources Statement.
  5. Improved File IO API
  6. Support for Non-Java Languages: invokedynamic
  7. Binary Literal/Underscore in Literals
  8. Fork-Join

 

Step 1 : Download JDK7 from the link below –

http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html

After downloading the JDK7, execute the file, it will install JDK7 in your directory.

Step 2 : Access your directory and set path for JDK7  –

For example – here we will develop our java programs (based on Java7) in “c:\sun” directory. You may choose any location to write your java programs. We will set path only for this directory.

Alternatively we can do it permanently via environment variables too.


 

Step 3 :    Create a file “Test.java”. Copy and paste the code below –

public class Test{

public static void main(String[]arg){

String type=arg[0];

switch(type){
case "Hello":
        System.out.println("You input- Hello");
        break;
case "Hi":
        System.out.println("You input- Hi");
        break;
default:
        System.out.println("Oh! come on!");
}
}//main method
}//Test class

Step 4 :    Compile and run the program as follows.



The string handling in switch..case is introduced first time ever in JDK. So the program above will not be compiled in the version below JDK7. Try to run the same program using JDK6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值