Fundamentals 6 min read

Java Fundamentals: A Beginner’s Guide to Identifiers and Keywords

This note explains Java identifiers—allowed characters, first‑character rules, valid and invalid examples—lists all language keywords that cannot be reused as names, and outlines practical naming conventions for classes, methods, constants, and packages to improve code readability.

Lisa Notes
Lisa Notes
Lisa Notes
Java Fundamentals: A Beginner’s Guide to Identifiers and Keywords

Java’s basic syntax resembles C/C++ but is a pure object‑oriented language that omits rarely used features such as pointers, making it simpler to learn.

Identifiers

Identifiers name classes, objects, variables, methods, types, arrays, and files. In Java they may contain letters, digits, underscores (_) and dollar signs ($). The first character must be a letter or underscore, never a digit.

Examples of valid identifiers: Name name $888 $123name Examples of invalid identifiers: 8address No.8 &445 Java is case‑sensitive, so Name and name are distinct identifiers.

Keywords

Keywords are reserved words that have special meaning to the Java compiler and cannot be used as identifiers. The following are the common Java keywords:

abstract

boolean

break

byte

case

catch

char

class

const

continue

default

do

double

else

enum

extends

final

finally

float

for

goto

if

implements

import

instanceof

int

interface

long

native

new

package

private

protected

public

return

short

static

strictfp

super

switch

synchronized

this

throw

throws

transient

try

void

volatile

while

Words such as true, false, and null are reserved literals, not keywords, and also cannot be used as identifiers. Reserved words are placeholders for potential future keywords.

Naming Conventions

When defining identifiers, follow the “self‑descriptive” principle so that names convey their meaning and improve readability.

Compound identifiers : concatenate words without spaces, e.g., phonePrice.

Class names : capitalize the first letter of each word (PascalCase), e.g., TeacherHelloWorld.

Method and variable names : start with a lowercase letter; subsequent words begin with an uppercase letter (camelCase), e.g., queryTeacher() or stuName.

Constant names : use all uppercase letters with underscores separating words, e.g., PI, MIN_VALUE.

Package names : all lowercase, dot‑separated, e.g., com.example.

Javanaming conventionsprogramming basicskeywordsIdentifiers
Lisa Notes
Written by

Lisa Notes

Lisa's notes: musings on daily life, work, study, personal growth, and casual reflections.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.