1. Home
  2. Computing & Technology
  3. Java

Java Is Case Sensitive

By , About.com Guide

Whether a programming language should be case sensitive or not tends to divide opinion amongst programmers. Regardless of the debate it's important to remember that Java is case sensitive.

What Does Being Case Sensitive Mean?

It simply means that the case of the letters in your Java programs matter. For example, suppose you decide to create three variables called "endLoop", "Endloop", and "EnDlOoP". Even though in English we see the variable names as saying the same thing, Java does not. It will treat them all differently.

Case Sensitive Tips

If you follow these tips when coding in Java you should avoid the most common case sensitive errors:

  • Java keywords are always written in lowercase. You can find the full list of keywords in the reserved words list.
  • Avoid using variable names that only differ in case. Like the example above, if I did have three variables called “endLoop”, “Endloop”, and “EnDlOoP” it would not take much for me to mistype one of their names. I then might find my code changing the value of the wrong variable by mistake.
  • Always make sure the class name in your code and java filename match.
  • Follow the Java naming conventions. If you get into the habit of using the same case pattern for different identifier types then the chances of you not making a typing mistake will increase.
  • When using a string to represent the path of a filename, i.e. "C:\JavaCaseConfig.txt" make sure you use the right case. Some operating systems are case insensitive and don't mind that the filename isn't exactly right. However, if your program is used on an operating system that is case sensitive it will produce a runtime error.
Explore Java
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java
  4. Java Syntax
  5. Java Is Case Sensitive>

©2009 About.com, a part of The New York Times Company.

All rights reserved.