case sensitive : Java Glossary
home C words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish 2007-05-18 by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
case sensitive
If you compare two strings in a case sensitive way, e.g. with String.compareTo, they are considered different if they differ only in capitalisation. If you compare two Strings in a case insensitive way, e.g. with String.compareToIgnoreCase, then they are considered equal if they differ only in capitalisation.

Java, the language, is case sensitive. Capitalisation must be precise in class, method and variable names. avar is not the same variable as aVar. However, the underlying operating system may be case insensitive, e.g. Windows. To Java, MyApp.class and Myapp.class are totally different files, but to Windows they are the same. To avoid problems, never name two different classes (or any other entities for that matter) with names differing only in capitalisation. The one possible exception is to name a local variable the same as its class, with the leading cap change to lower case, e.g. MyApplet myApplet = new MyApplet(); The OS never sees these local variable names.

Resources, resource bundles, jar members generally and images all need the correct capitalisation. Again for safety, file names should be correct too, though Windows permits sloppiness.

Gotchas

Even if your OS is case insensitive, it is best to treat as if it were case insensitive. Otherwise, the following nasty things will eventually happen to you.

Converting Case

String.toUpperCase, String. toLowerCase, Character.toUppercase and Character.toLowerCase are much more complicated internally than you would imagine with all manner of coded cultural lore on how caps are done for various symbol sets, including chars that change length. If you are just dealing with English, you can use the much faster version part of the StringTools package.


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] The information on this page is for non-military use only.
You are visitor number 12,812. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/casesensitive.html J:\mindprod\jgloss\casesensitive.html