
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why we should follow the naming conventions in Java?
Naming conventions in Java make programs more understandable by making them easier to read.
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.
Why should follow the Java naming standards
- To reduce the effort needed to read and understand source code.
- To enable code reviews to focus on more important issues than arguing over syntax and naming standards.
- To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences.
Naming Conventions for a different type of Identifiers
Package
- The Package name should be in all lower case.
Example
package com.tutorialspoint;
Interface
- The Interface name should start with an upper case character.
Example
interface TutorialsPointInterface { // some statements }
Class
- All the words of a class name should start with an upper case character.
Example
class TutorialsPointClass { // some statements }
Method
- Methods should be verbs with the first letter lowercase and the first letter of each internal word capitalized.
Example
class TutorialsPointClass { void printMessage() { } }
Variable
- The first word should be in lower case and the internal words start with capital letters.
- Variable names should not start with underscore _ or dollar sign $ characters.
Example
class TutorialsPointClass { int rollNum; String firstName; String lastName; }
Constant
- All the characters should be in upper case.
Example
class TutorialsPointClass { public static final int MAX_score = 100; }
- Related Questions & Answers
- Java Naming conventions
- CamelCase in Java naming conventions
- variable naming conventions of java
- Advantages of naming conventions in Java
- Naming Conventions in C#
- Explain naming conventions for packages in java?
- What are Variable Naming Conventions in JavaScript
- How to define the naming conventions for JSON field names in Java?
- Why we should use whole string in Java regular expression
- Why we should use set.seed in R?
- Why should we use MySQL CASE Statement?
- Why should we not use ++, -- operators in JavaScript?
- Why should we use a StringBuffer instead of a String in Java?
- Why we should avoid using std::endl in C++
- Why do we use import statement in Java? Where it should be included in the class?
Advertisements