Skip to content

mehrdad-javan/g51-java-lecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Naming Conventions

In Java, naming conventions are essential for readability and maintenance of the code. Following these conventions makes it easier for others to understand your code and reduces the chance of errors.

1. Packages

  • Convention: Lowercase letters, separated by dots.
  • Example: com.example.myapp

2. Classes and Interfaces

  • Convention: Nouns, starting with an uppercase letter. Use camel case for multiple words.
  • Class Example: MyClass
  • Interface Example: MyInterface

3. Methods

  • Convention: Verbs, starting with a lowercase letter. Use camel case for multiple words.
  • Example: calculateTotal

4. Variables

  • Convention: Start with a lowercase letter. Use camel case for multiple words.
  • Example: totalAmount

5. Constants

  • Convention: Uppercase letters, words separated by underscores.
  • Example: MAX_VALUE

6. Enums

  • Convention: Uppercase letters, words separated by underscores.
  • Example: COLOR_RED

7. Type Parameters

  • Convention: Single uppercase letter.
  • Example: T, E, K, V

8. Annotations

  • Convention: Use the @ symbol followed by the annotation name, which should start with an uppercase letter.
  • Example: @Override

Summary

  • Packages: com.example.myapp
  • Classes: MyClass
  • Interfaces: MyInterface
  • Methods: calculateTotal
  • Variables: totalAmount
  • Constants: MAX_VALUE
  • Enums: COLOR_RED
  • Type Parameters: T, E
  • Annotations: @Override

Following these naming conventions ensures that your code adheres to industry standards, making it more readable and maintainable.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages