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
disheng wang
5,422 PointsConfusing of import in java
HI, I have a question about java import class.
Why do we flip the order when we import the local class but not the global classes?
for example:
import com.treehouse.Treet;
import java.util.Date; // this one is follow the order.
thanks.
1 Answer
Dane Parchment
Treehouse Moderator 11,077 PointsI am not sure if I am understanding your question correctly, but I will attempt to answer it anyway to the best of my knowledge.
In all honesty, order doesn't really matter with import statements, you can import them like so if you wanted to:
import java.util.Date;
import com.treehouse.Treet;
And it will still perform the same as the following import order:
import com.treehouse.Treet;
import java.util.Date;
It is typically up to the company/developer or the style guide that the developer is using to determine the order of imports, and I guess Treehouse is teaching the method where you import via order of local classes and packages first, and then the java classes after.
If I misunderstood your question please let me know so that I can re-write my answer.
disheng wang
5,422 Pointsdisheng wang
5,422 PointsThanks for the answer! This is what I need, Sorry about my English.