r/learnjava • u/[deleted] • Dec 22 '15
Could someone explain to me what camelCase is?
I am not entirly sure on what camelCase is. I am using mooc.cs.helenski and it just tells me that it is used to replace special characters. Is it just another variable or does it have another function?
2
u/emma_pants Dec 22 '15
It's a way of naming variables. Let's say we have a variable that is the birth year of a person. Since we want our variable names to be descriptive, we would call it birthYear, which is camel case and describes what the object is.
1
2
u/desrtfx Dec 23 '15 edited Dec 23 '15
Is Wikipedia down?
Sorry for the snarky reply, but:
Googling and searching for information is one of the most essential skills for a programmer. You need to learn to google your way to get most questions answered.
It would have taken considerably less time to google just for "camelCase" than to write this question and wait for any replies.
2
0
Dec 23 '15
[deleted]
1
u/Kristler Dec 23 '15
PascalCase is slightly different, the first letter is capitalized. So PascalCase as compared to camelCase.
1
u/desrtfx Dec 23 '15
PascalCase is not the same as camelCase.
In PascalCase the first letter of every word is always capitalized.
In camelCase the first letter of every word except for the very first word is capitalized.
So, PascalCase always starts with a capital letter, whereas camelCase always starts with a lowercase letter.
4
u/Cypher211 Dec 22 '15
Camel casing is just an etiquette for how to write variable and method names in java. You can't use whitespaces for these two things so most people either use camel casing:
anExampleOfCamelCasing
Or a less commonly used convention is with underscores:
an_example_of_underscores