packagecom.company;importjava.text.DateFormat;importjava.text.SimpleDateFormat;importjava.util.*;publicclassMain{publicstaticvoidmain(String[] args){// write your code here// demoSet();//// demoKeyValue();// demoException();// demoRandom();demoDate();}publicstaticvoiddemoDate(){Date date =newDate();DateFormat df =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss");System.out.println(date);System.out.println(df.format(date));System.out.println(UUID.randomUUID());System.out.println(Math.log(22));}publicstaticvoiddemoRandom(){Random random =newRandom();/**
* 随机种子
*///random.setSeed(100);for(int i =0; i <4;++i){System.out.println(random.nextInt(100));}}publicstaticvoiddemoException(){try{String a =null;
a.indexOf('a');}catch(NullPointerException e){System.out.println("yyyyy");}finally{System.out.println("fff");}}publicstaticvoiddemoSet(){Set<String> stringSet =newHashSet<String>();for(int i =0; i <3;++i){
stringSet.add(String.valueOf(i));
stringSet.add(String.valueOf(i));
stringSet.add(String.valueOf(i));}System.out.println(stringSet);}publicstaticvoiddemoKeyValue(){Map<String,String> map =newHashMap<>();for(int i =0; i <4;++i){
map.put(String.valueOf(i),String.valueOf(i*i));}for(Map.Entry<String,String> entry : map.entrySet()){System.out.println( entry.getKey()+":"+ entry.getValue());}}}