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 trialPaul Taylor
2,213 Pointsmethod above constructor
Have a question? Wondering why it best for myself to add a method beneath the constructor and above it?
public class GoKart {
private String mColor;
public GoKart(String color) {
mColor = color;
}
public String getColor() {
return mColor;
}
}
3 Answers
anil rahman
7,786 PointsIt is usually just best practice that when a class is called it gets to the constructor first. So we end up following this rule of having constructor first then methods below that.
Paul Taylor
2,213 PointsSo pretty much its just the way things operate, and thank you much.
anil rahman
7,786 PointsYh pretty much just how it goes. People would expect to see a constructor first in your class code. :)