Use Java Naming Conventions

 class​ Rover {
»static​ ​final​ ​double​ WalkingSpeed = 3;
 
»final​ String SerialNumber;
»double​ MilesPerHour;
 
» Rover(String NewSerialNumber) {
  SerialNumber = NewSerialNumber;
  }
 
»void​ Drive() {
  MilesPerHour = WalkingSpeed;
  }
»void​ Stop() {
  MilesPerHour = 0;
  }
 }

We have to name a lot of stuff in Java: packages, classes, interfaces, enums, methods, variables, fields, parameters, and constants. Take a look at the code above—it contains a lot of names. Do you notice anything strange? Can you see the pattern?

We consistently named everything in CamelCase: no spaces, and all words start with a capital letter. As long as we’re consistent, we can choose any way of naming, can’t we?

Well, in theory ...

Get Java By Comparison now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.