The Java posts on this page are based on what I learned from the book Jump to Java, interpreted and organized in my own way. If you find any mistakes or inaccuracies, please feel free to let me know, I’ll review and correct them as soon as possible.
In Java, naming isn’t just a matter of style, it’s a fundamental part of writing readable, consistent, and maintainable code.
Interestingly, these rules are not enforced by the compiler.
You could technically write
public class studentinfo {}
Java
복사
and Java would compile it just fine. But while the compiler doesn’t care, developers do. That’s because naming conventions in Java are not system-imposed laws.
Howerver, rather a cultural agreement among developers , a shared understanding that clean, consistent naming makes collaboration easier, reduces confusion, and allows anyone to understand code at a glance.
In short, naming conventions are not syntax rules; they’re social contracts.
Class Naming
The Rule : PascalCase (capitalize the first letter of each word)
Class names should begin with a capital letter, and each word that follows should also start with a capital letter — this is known as PascalCase.
Because a class represents an entity or concept, the name is typically written as a noun.
public class StudentInfo { }
public class OrderManager { }
public class FileReader { }
Java
복사
A name like StudentInfo clearly describes “a class representing student information,”
while FileReader naturally implies an object that reads files.
Summary of Rules
•
•
•
•
•
Why Nouns?
A class describes what something is, not what it does. That’s why names like Car, Invoice, or UserAccount feel intuitive, they reflect real-world entities.
Bad Examples
public class processData {} // Verb form — should be a method name
public class datahandler {} // Starts with lowercase — violates convention
public class STUDENT {} // All caps — hard to read
Java
복사
Practical Tip
Think of your class names as the “nouns of your codebase.” By just skimming the class names, someone should be able to grasp the core structure and purpose of your entire application.
Method Naming
The Rule : camelCase (start with lowercase)
Method names start with a lowercase letter, and subsequent words begin with uppercase, is camelCase.\
Because methods express actions or behaviors, they should be written as verbs.
public void printMessage() { }
public int getUserAge() { return age; }
public boolean isValidUser() { return true; }
Java
복사
Summary of Rules
•
•
•
•
•
Why Verbs?
Methods describe actions, so naming them like commands makes the code read like natural language.
user.validate();
order.calculateTotal();
Java
복사
This “sentence-like readability” is one of the key principles behind Java’s naming philosophy.
Bad Examples
public void userData() {} // Not an action — unclear intent
public void Process() {} // Starts with capital letter — looks like a class
public void dothis() {} // No word separation — unreadable
Java
복사
Practical Tip
A method name should reveal its intent without reading the implementation.
getTotalPrice() is good, calculate() is vague. Adding the object of the action makes a method instantly self-explanatory — saveFile() is always better than just save().
Variable Naming
The Rule : camelCase (start with lowercase)
Variables hold data, so they should be descriptive nouns representing that data.
Like methods, they use camelCase, but instead of describing an action, they describe a thing or concept.
int studentCount = 30;
String userName = "Hyunwoo";
double taxRate = 0.1;
Java
복사
Summary of Rules
•
•
•
•
•
public static final int MAX_USER_COUNT = 100;
public static final double PI = 3.14159;
Java
복사
Why Positive Form?
Boolean variables like isActive or hasPermission make if statements read naturally
if (isActive) { ... } // reads clearly
if (!isActive) { ... } // instantly understandable
Java
복사
Names like notLogin or flag1 are confusing, they force readers to decode logic instead of just reading it.
Bad Examples
int x = 10; // meaningless
boolean notLogin = false; // negative form — confusing
String a = "user"; // too short to be descriptive
Java
복사
Practical Tip
Your variable name is the first comment explaining what that data represents.
Good variable names make code self-documenting.
•
price → vague
•
priceInWon → clear
•
totalPrice → contextual and precise
The more context your variable provides, the fewer bugs you'll have.




