Jshell

一 、安裝jdk9

 

方法一java

sudo apt install openjdk-9-jdk-headless
 linux

方法二shell

下載jdk9:
hg clone http://hg.openjdk.java.net/jdk9/jdk9 openjdk9bash

cd openjdk9 && sh ./get_source.shless

# 編譯
bash ./configure 測試

#  make
make all
cd build/linux-x86_64-normal-server-release/images/ui

# 使用jshell
jdk/bin/jshellspa


二 、試驗Jshell

打印一個hello world.net

試驗了一下Calendar類code

# dpc @ dpc-thinkpad in /export/service/kulla-dev/openjdk9/build/linux-x86_64-normal-server-release/jdk [22:20:23] 
$ bin/jshell 
|  Welcome to JShell -- Version 9-internal
|  For an introduction type: /help intro


jshell> System.out.println("hello world")
hello world

jshell> Cal
Calendar   Callable   

jshell> Cal
Calendar   Callable   

jshell> Calendar.get
getAvailableCalendarTypes()   getAvailableLocales()         
getInstance(                  

jshell> Calendar.getInstance(
getInstance(   

jshell> Calendar.getInstance()
$2 ==> java.util.GregorianCalendar[time=1476195674501,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=9,WEEK_OF_YEAR=42,WEEK_OF_MONTH=3,DAY_OF_MONTH=11,DAY_OF_YEAR=285,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=10,HOUR_OF_DAY=22,MINUTE=21,SECOND=14,MILLISECOND=501,ZONE_OFFSET=28800000,DST_OFFSET=0]

jshell> Calendar.getInstance().get(Display all 447 possibilities? (y or n)

jshell> Calendar.getInstance().get(Cal)
Calendar   Callable   

jshell> Calendar.getInstance().get(Calendar.D)
DATE                   DAY_OF_MONTH           DAY_OF_WEEK            
DAY_OF_WEEK_IN_MONTH   DAY_OF_YEAR            DECEMBER               
DST_OFFSET             

jshell> Calendar.getInstance().get(Calendar.DA)
DATE                   DAY_OF_MONTH           DAY_OF_WEEK            
DAY_OF_WEEK_IN_MONTH   DAY_OF_YEAR            

jshell> Calendar.getInstance().get(Calendar.DAY_OF_)
DAY_OF_MONTH           DAY_OF_WEEK            DAY_OF_WEEK_IN_MONTH   
DAY_OF_YEAR            

jshell> Calendar.getInstance().get(Calendar.DAY_OF_WEEK)
DAY_OF_WEEK            DAY_OF_WEEK_IN_MONTH   

jshell> Calendar.getInstance().get(Calendar.DAY_OF_WEEK))
$3 ==> 3

jshell> Calendar.getInstance().get(Calendar.DAY_OF_MONTH)
$4 ==> 11

jshell> Calendar.getInstance().get(Calendar.DAY_OF_YEAR)
$5 ==> 285

jshell> Calendar.getInstance().get(Calendar.HOUR)
HOUR          HOUR_OF_DAY   

jshell> Calendar.getInstance().get(Calendar.HOUR))
$6 ==> 10

留圖記念。

 

有了這玩意之後忘記哪一個語法了,或者臨時作個小測試,驗證個小思路,sublist,subStr這樣子的,不用再費勁建個class了。

相關文章
相關標籤/搜索