Every Day

1、取得key的list
  
   def ddd = ['aa':11,'bb':22,'cc':33]
   def ccc = ddd.keySet()
   print ccc
   // [aa, bb, cc]
   

2、包含
 
   def ddd = ['a','b','e','d']
   print ddd.contains('sa')
   print " "
   print ddd.contains('a')
   print " "
   print 'ab' in ddd  
   print " "
   print 'a' in ddd  
   print " "
   // false true false true

3、随机 取整
   // 随机出 0~5的整数,int为取整操作
   (int)(Math.random()*6)
   // 四舍五入
    def ddd = 0.63
    print Math.round(ddd)+" # "
    print ((int)(ddd+0.5))
    // 1 # 1

你可能感兴趣的:(java)