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
A X
12,842 PointsBasic Java Concepts
I'm really struggling to understand some basic Java concepts, and I'm hoping someone can help me...and please use a beginner's level explanation. I don't understand the differences between public and private, and also between void and static. When I look online or elsewhere in the forum for answers, the answers are always above my level of understanding. Thanks for understanding and your help.
1 Answer
Anthony Branze
4,887 PointsHey, Okay so here is a great way for a beginner to look at it, I had the very same problem. Public variables are variables that can be accessed by any of the program at any time anywhere in the program by all classes. Private variables are different in the sense that they are "private" to the specific class you declared the variable in. consider this. your in a house. your door is public FrontDoor. but your back door is private BackDoor. and only people who hold the key can enter the back door. but anyone can come in the front. does that help clear things up a little?
Anthony Branze
4,887 PointsAnthony Branze
4,887 PointsVoid is simply setting up a method that returns no value. and static means that the method is part of the class.