Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Closeable.java Question

 
Harry Preston
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JDK, Closeable.java

But AutoCloseable is located java.lang

Question
How does Closeable know where to find AutoCloseable?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harry,
Good question! java.lang is a special package. It is automatically imported whether the class specifies it or not. Other common classes like Integer and String are located in that package as well. That's why you can just write Integer.parseInt("111") without having to import anything.
 
Harry Preston
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, thanks much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic