cosmicsafari
cosmicsafari

Reputation: 4049

Java: Method name conventions

This is more out of curiosity than anything else, just wondering what are the most common naming conventions for method names?

Start with a capital

GetName() 

or start lowercase and then capitals for each new word

getName()

or something else.

Upvotes: 0

Views: 4155

Answers (3)

DBroncos1558
DBroncos1558

Reputation: 141

In Java, the naming convention for methods is getName()

Variables also follow the same naming convention as methods, for example. getNameExample

The naming convention used for classes capitalizes every word ex. GetName

Upvotes: 0

christopher
christopher

Reputation: 27346

In Java, the convention is to have the first word with a lower case, and the rest with upper case.

public void getName()

Also, constants are declared in full capitals:

public final int MAX_USERS

Upvotes: 0

Crozin
Crozin

Reputation: 44396

Java uses camelCase convention for method names.

You can read more about conventions in Java in this document: Code Conventions for the Java Programming Language

Upvotes: 6

Related Questions