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 PointsNo need to import Character? Importing isn't better than just using?
1) The some previous class, I learned about import, import java.io.Console on the top in Prompter.java. But what I couldn't catch is... why do we need to import Console? I thinks there is some different point that I can't catch. "import java.io.Console" VS "import java.lang.Character"
2) <Prompter.java> : the practice code import java.io.Console; Console console = System.console();
With the practice code, I imagined like below.
<Game.java> import java.lang.Character; Character character = new Character();
or (just) Character character = new Character();
which one is correct?
3) if we import Character on the top in Game.java, we don't need to use "Character".isLetter We can just use isLetter.
Just want to know why he didn't import? Does it has any convention to import?
1 Answer
Seth Kroger
56,413 Pointsjava.lang is a special package that contains classes that are core to the Java language and all classes in it are automatically imported. Importing them yourself is redundant.