Java Naming Conventions - Javatpoint
Java Naming Conventions - Javatpoint
com/java-naming-conventions
1 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
But, it is not forced to follow. So, it is known as convention not rule. These conventions are suggested by
several Java communities such as Sun Microsystems and Netscape.
All the classes, interfaces, packages, methods and fields of Java programming language are given according
to the Java naming convention. If you fail to follow these conventions, it may generate confusion or
erroneous code.
By using standard Java naming conventions, you make your code easier to read for yourself and other
programmers. Readability of Java program is very important. It indicates that less time is spent to figure out
what the code does.
The following table shows the popular conventions used for the different identifiers.
2 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
Variable It should start with a lowercase letter such as id, name. class Employee
It should not start with the special characters like & (ampersand), {
$ (dollar), _ (underscore). // variable
If the name contains multiple words, start it with the lowercase int id;
letter followed by an uppercase letter such as firstName, //code snippet
lastName. }
Avoid using one-character variables such as x, y, z.
3 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
Java follows camel-case syntax for naming the class, interface, method, and variable.
If the name is combined with two words, the second word will start with uppercase letter always such as
actionPerformed(), firstName, ActionEvent, ActionListener, etc.
← Prev Next →
Feedback
4 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
React Native Python Design Python Pillow Python Turtle Keras tutorial
tutorial Patterns tutorial tutorial Keras
React Native Python Design Python Pillow Python Turtle
Patterns
Preparation
Trending Technologies
Machine DevOps
Learning Tutorial
Tutorial DevOps
Machine
Learning
5 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
B.Tech / MCA
6 of 7 21/09/2023, 11:53
Java Naming Conventions - Javatpoint https://www.javatpoint.com/java-naming-conventions
7 of 7 21/09/2023, 11:53