Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import java.util.{ArrayList, List => JList}
  2.  
  3.  
  4. class TestFirst {
  5.  
  6. implicit def jList2RichList[T](list: JList[T]) = new {
  7. def head: T = if (list.size > 0) list.get(0) else null.asInstanceOf[T]
  8. }
  9.  
  10. def doTest {
  11. val jList = new ArrayList[String]()
  12. jList.add("a")
  13. jList.add("b")
  14. println(jList.head)
  15.  
  16. val jList2 = new ArrayList[String]()
  17. println(jList2.head)
  18. }
  19. }
Add Comment
Please, Sign In to add comment