Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class name convention in java [closed]

What is the naming convention of classes in java, for example should all classes be in upper case like MYCLASS.java ?

as some classes like com.sun.org.apache.bcel.internal.generic. ANEWARRAY. can be found in Sun's library as well

Note: I have read all naming convention from Oracle but I could not find anything which says we should name a class with All Uppercase.

like image 576
ankit Avatar asked May 14 '13 07:05

ankit


People also ask

What is the naming convention for class names Java?

In Java, class names generally should be nouns, in title case with the first letter of each separate word capitalized. and interface names generally should be adjectives, in title case with the first letter of each separate word capitalized.

What are the two naming conventions in Java?

Using the right letter case is the key to following a naming convention: Lowercase is where all the letters in a word are written without any capitalization (e.g., while, if, mypackage). Uppercase is where all the letters in a word are written in capitals.

Which is the correct naming convention for Java method?

Java uses CamelCase as a practice for writing names of methods, variables, classes, packages, and constants.

What are the three Java naming convention?

Variables should be named using camelCasing. Variable names should always start with a lower case letter. Packages should be named using snake_casing. Package names should always start with a lower case letter.


2 Answers

Class Names should be in CamelCase. Try to use nouns because a class is normally representing something in the real world.

The Documentation states the following:

Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).

like image 115
CloudyMarble Avatar answered Sep 19 '22 21:09

CloudyMarble


Java has a very well described naming / coding convention.

You can look it up here http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html

Technically it doesn't matter how you name you classes as long as public classes are in a .java-source file with the same name as the class.

like image 42
Ozzie Avatar answered Sep 21 '22 21:09

Ozzie