3

I am a newbie to Java and just starting to learn the language but I am hitting a few snags along the way and I was hoping you can give me some direction on an issue I am having.

I know Java is case sensitive when it comes to things like variables and some reserved words. However I cannot wrap my head around which ones to use lower case and which ones to use upper case. For example I know you have to use lower case on class. But for System you have to use capital S or it will error during the compile phase.

Can someone give me some help understanding when to use upper and when to use lower case for java commands? Is everything lowercase unless I reference another object and then does it depend if that object is saved with and uppercase or lowercase name?

2

4 Answers 4

4

You need to read, understand and use the Oracle java coding guidelines, here you go:

http://www.oracle.com/technetwork/java/codeconv-138413.html

Naming section:

http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367

Sign up to request clarification or add additional context in comments.

1 Comment

Specifically on naming
1

The most accurate answer is "use the same case as the name you are using". So, if the class is called System, you have to write System. If the method is called print, you have to write print.

I realise that this is not immediately helpful, but it is the truth, and it is something you will need to learn to cope with.

Other answers are giving you very helpful general rules about the casing of types (classes are UpperCamelCase, methods are lowerCamelCase, constants are UPPER_WORM_CASE), but the thing is, there are exceptions. Not many in the JDK code, but in libraries you pull in and codebases you inherit, there will be exceptions. In a codebase i work on, there are numerous enum constants whose names are UpperCamelCase instead of the proper ALL_CAPS_WORM_CASE, and our convention is for test methods, and many testing utility methods, to be named in lower_worm_case.

So, the really important thing to learn and internalise is that the name you write must match the name as defined. That is the only true rule that applies.

Comments

0

Try using this:http://en.wikiversity.org/wiki/Learning_Java

It will help you learn Java and has can help you to navigate any issues you may have at the beginning.

Comments

0

the following is useful,simple variables = starting with lowercase,Class Name = starting with uppercase,Final variable = all capital ,methods = starting with small letter

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.