Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Efficiency! Design the UI

A few questions.

Hello, I have a couple of questions regarding this video:

  1. I don't understand what 'System.in' does...
  2. What does 'Buffered' and 'InputStream' reader do?
  3. What is the difference between 'System.out.printf' and 'System.out.print'?

Thanks!

1 Answer

I am no Java expert, and have yet to scratch the surface of Oracle's Java documentation, but here is what I understand everything to mean.

1 . System.in is the opposite of System.out.print. Instead of writing data to the console using System.out, you use System.in to read input from the console.

2 a. Buffered Streams (Buffered) is similar to how when you watch Netflix and you notice the circle spinning as it is waiting to load more of your video clip. More specifically, unbuffered input/output is handled by the underlying OS. This makes your program very inefficient and since each request requires a lot of operations to take place for each byte of data. When you use buffers, you read data is large chunks and store it in a buffer, then you look at that data one-by-one.

2 b. Streams like InputStream are for reading and writing text. If you're not reading or writing to a console (i.e. not using System.in/System.out you are using Streams). I just think reading data is System.in if it is from the console and InputStream if it is a file.

3 . System.out.printf = System.out.format, which is a formatted string. I can not really think of a way to explain this so I will link you to this blog.