Identifiers are programmer-defined names used for variables, methods, classes, packages, and interfaces in Java. They make the program more readable and meaningful.
Identifiers are programmer-defined tokens used to give names to program elements.
Examples include names of variables, methods, classes, and interfaces.
_) and dollar ($) characters.arena
s_count
marks40
class_one
1sst // starts with a digit
2nd number // contains a space
oh!god // contains illegal symbol '!'
Always choose meaningful names for identifiers, following camelCase or PascalCase conventions for better readability.
camelCase (e.g., studentAge, totalMarks)camelCase (e.g., getStudentName(), calculateTotal())PascalCase (e.g., StudentRecord, EmployeeDetails)UPPER_CASE with underscores (e.g., MAX_VALUE, PI)com.prowessapps.java)| Identifier Type | Convention | Example |
|---|---|---|
| Variable | camelCase | studentAge |
| Method | camelCase | getStudentName() |
| Class / Interface | PascalCase | StudentRecord |
| Constant | UPPER_CASE | MAX_VALUE |
| Package | lowercase | com.prowessapps.java |
studentAge instead of x).HTMLParser).π₯ Download the Java Identifiers & Naming Conventions Cheatsheet (PDF)
Topic: Identifiers | Language: Java