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 trialTrudy Lee
2,812 PointsWhy do I need to import java.io.console? Need more explain... Are we import java.io.console in the previous class?
Why do I need to import java.io.console? Need more explain... Did we import java.io.console in the previous class like to use printf or println?
1 Answer
michalm
7,343 PointsWhenever we want to access an object that is not included in our package (this will make more sense as you dive deeper into Java) we need to import it as shown in this example. This is basically a way of telling Java that we want to use functionality offered by one of the objects without actually going through the struggle of copying over its source classes to our workspace.
Real life example of this would be streaming services - modern gaming tablets offer service of streaming games from powerful PCs that we are accessing remotely. This means we can play recent releases with highest settings from comfort of our own sofa, without actually owning those gaming desktops. Same applies to importing classes - we are accessing their functionality without actually "owning" them.
Trudy Lee
2,812 PointsTrudy Lee
2,812 PointsThoughtful answer! Thanks