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 trialfilibonio hernandez
2,826 PointsHey there do you have to use Camel Casing on Variables too?
So I am wondering about this question because when the teacher is creating the code he puts a capital N in name in the variable like this:
String firstName = "etc";
how come the variable is put in that way the capital n in name and no capital f in first. What I am really asking does it really matter to do it that way in Java.?
2 Answers
gyorgyandorka
13,811 PointsThe Java convention is that class (type) names should be in camel case (ThisIsAType
), while variable and method names in lower camel case (or "mixed case"), where the very first letter is lowercased (thisIsAnObjectOrAMethod
).
Kane Simmons
14,206 PointsHe actually mentions in the video that while not required, it is standard practice to use Camel Case when naming variables.
filibonio hernandez
2,826 Pointsfilibonio hernandez
2,826 Pointsahh okay that makes sense. but I'm wondering is it a necessity though in java why not have both lower case? or is it just how the java system works to put it that way.?
gyorgyandorka
13,811 Pointsgyorgyandorka
13,811 PointsThe aim of these conventions is just to make the code more readable - you can visually separate e.g. a type from an instance immediately by looking at the case which is used. They're not "enforced" in any way by the Java compiler though, if that's what you mean.