naming convention for class in java - all caps
Asked Answered
I

4

5

How do you name a class when it's all caps in Java? For example, if I want to create a class to select certain people to be VIP. Should I name the class "VIPSelector" or "VipSelector"?

Thanks!

Incontinent answered 30/6, 2020 at 3:43 Comment(1)
Classname should start from capital letter. Both are validCaphaitien
D
6

Both of your options work. The main goal with classes is to have them start with an Upper Case. So, VIPSelector and VipSelector both work. This convention is mostly used to get rid of a common mistake that you can find in OOP which is when you can't make the difference between a class and a method.

Imagine having a class object called "student", to initiate it, it would be student s = new student(); That looks a lot like a method and this is why, by convention, we put the first letter in upper case.

Dexterdexterity answered 30/6, 2020 at 4:7 Comment(0)
C
1

This is how class Name should be :

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).

Examples: class Raster; class ImageSprite;

Check this for the information : https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html#:~:text=Class%20names%20should%20be%20nouns,such%20as%20URL%20or%20HTML).

Caphaitien answered 30/6, 2020 at 3:47 Comment(0)
I
0

Both names are acceptable. The general convention for naming classes in Java is just that the first letter should always be capitalized and the whole name should be in camel case, meaning that the first letter of each word is capitalized.

Interlinear answered 30/6, 2020 at 3:47 Comment(0)
H
0

The google style guide prefers VipSelector

See this answer to a similar question.

Heyduck answered 30/10, 2022 at 16:23 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.