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 Basics Perfecting the Prototype Reviewing Our Feedback

Aditya Puri
Aditya Puri
1,080 Points

Why didn't we declare an object for the class "System"??

Why didn't we declare an object for the class "System" the way we did it for the class "Console"??

For the class "Console" we had to first make an object called "console" and then call on the methods.

But in the case of the class "System", we just directly called its method without making an object first. Why is this so?

2 Answers

Aditya Puri
Aditya Puri
1,080 Points

so the static methods do not need an object to be declared first? They can straight away be called in the class?

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Exactly. Take a look at good reasoning when to use static methods (second best answer):

http://stackoverflow.com/questions/2671496/java-when-to-use-static-methods

Very simple explanation for me, from there is this one:

Quote: "If any operation is not dependent on instance creation."