Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What exactly is System.in ?  RSS feed

 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look at this:

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Im so confused! What on earth is system.in? Is it an object of some sort?
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

System is a class. And "in" is a static variable of that class. And what that static variable is, is an InputStream for standard input.

Henry
 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmad Auada wrote:Im so confused! What on earth is system.in? Is it an object of some sort?


Welcome, Ahmad. Henry's answer is correct. Let me add that, in Java, case matters. So, "System.in" refers to a static variable that is a member of the "System" class. There is no "system" class in the Java libraries (and it is universal practice to use a capital letter as the first letter of a class name). So, when you use it, remember to capitalize the "S" in "System." Your code won't compile if you don't (unless you have a variable of your own, named "system," which would probably just be confusing in most cases).
 
Sachin Tripathi
Ranch Hand
Posts: 368
3
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and i add little more:

System class holds methods and fields which are specifically related to the computer you are using and the runtime you are running
 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I get it now!
Thanks guys! ยด=)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!