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 Using your New Tools Multiple Strings

Varun Singh
Varun Singh
1,905 Points

why do we write public in the start of every class for ex: public class TreeStory ?

public class TreeStory { //codes }

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Varun;

While we wait with high anticipation for the next Java course by Craig Dennis, I would recommend looking at a few online resources about accessor methods and the various ways one can control access to class members.

Here are some, perhaps, helpful links,

Controlling Access to Members of a Class - This is on Oracle's website, they are the current developers of the Java language and as such there is a ton of useful information.

Accessor Methods in Java - A Stackoverflow discussion on the subject.

A discussion on different class options

Those should get you started. As you will discover many languages utilize similar access control procedures so learning them in Java can be a great benefit down the road as well.

Great question and welcome to Treehouse!

Happy coding,

Ken

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Varun,

Public is an accessor method that describes who can use the class. We are going to be covering this in great detail in the course I just added to the roadmap:

http://teamtreehouse.com/library/java-objects/upcoming

Planning on an early December release, we shoot it tomorrow.

Hope it helps!