An identifier is simply the name you choose for the things you build in Java. When you write int totalPrice = 500; the word totalPrice is the identifier, while int is a keyword and 500 is a literal. That one line already contains all three ideas, which is why beginners often mix them up in the beginning.
Think of it the way you would think about naming a newborn. A legal name is not enough; a good name helps. totalPrice tells you what the number means, while x or d1 tells you nothing three months later. Java lets you name things fairly freely, but the language still sets a few hard rules.
Every one of these is an identifier, because you chose the name yourself:
- A class name such as InvoiceProcessor
- A variable name such as customerAge
- A method name such as calculateTotal
- A package name such as com.mycompany.billing
- A constant name such as MAX_RETRIES