• Post Reply Bookmark Topic Watch Topic
  • New Topic

java IO Class  RSS feed

 
kethare eswaran
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.in is in java.lang,but we use this in Geting Input using BufferedReader

(ie)
BufferedReader br= new BufferedReader(new InputReader(System.in))

BufferedReader is in Java.IO and System.in is in JAVA.LANG

how is it possible?

help me
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not exactly sure what you are asking here, but it is possible, in fact, necessary, to reference a class in one package from another package. You use java.lang classes in your own class which, if not specifically declared to be in a package, belongs to an anonymous package distinct from java.lang.
[ July 12, 2006: Message edited by: Joe Ess ]
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the classes in Java are located in a package. If the class is not declared in particular package it is said that the class is in the default package.

The declaration of the package of class appears at the beginning of the source file. Somewhat like this: package java.io.InputStream or java.lang.String.

For instance, this code is valid:



Now, a class should be referenced using it fully qualified named, but if you want to avoid the use of such long names as java.java.util.concurrent.locks.Lock, then you can import the class so that you can use its canonical name.

Somewhat like this:



I hope this helps clarifies your doubt.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!