views:

253

answers:

7

Hi This is the question I am still searching for proper answer , this may be basic question but I like to ask here.. I read Java is case sensitive.. I am not confirmed.. If it is case sensitive then what is the specific reason it has been made case sensitive?

Thanks..

+6  A: 

Yes it is case-sensitive. It is this way because of it's inheritance from C. To keep the language more familiar to what people were used to "in the day", they left it as case-sensitive. There is an added advantage, since Java identifiers can be almost any unicode character, you don't have to worry about whether or not an individual character can be uppercased or not.

For example, should ß be equivalent to ss?

Paul Wagland
+4  A: 

Identifiers are case-sensitive because collation is a difficult, locale-dependent problem.

Tobu
Unicode collation defines a preorder, which means it *also* defines case-insensitive comparison.
Tobu
I stand corrected; sorry. I can't change the vote anymore, though since Joel and Jeff decided it'd be a good idea that discussions will never sway one's opinion.
Joey
Thanks, and I'd rather ignore the positive reinforcement thingie.
Tobu
+2  A: 

Yes. Java is case-sensitive because most programming languages are!

Alex Baranosky
+4  A: 

Java is case-sensitive because it uses a C-style syntax. Case sensitivity is useful because it lets you infer what a name means based on it's case.

For example, the Java standard for class names is uppercasing the first letter of each word (Integer, PrintStream, etc). The standard for variable and method names is lowercase the first letter of the first word, and uppercasing all other first letters (number, println(), checkError(), etc). And the standard for constants is all uppercase with underscores (SOME_CONSTANT).

While you're not required to follow these rules in your code (it'll compile even if you break these rules), Java's built-in code follows them, and all major Java libraries do too. And your code really should follow these rules too, because it helps other developers infer meaning when they see the capitalization.

Kaleb Brasee
+2  A: 

This was more a technical decision. Java is intented to be platform independent. Public Java classes are stored with the package/classname in the filesystem. In non-Windows platforms the filenames are case sensitive. It would fail over there if you didn't use an exact case to load/run the class. This need for case sensitivity is extended to other identifiers in Java (which in end yields room for other (but non-technical) advantages like naming conventions).

BalusC
+1  A: 

The Java compiler and interpreter are case-sensitive, so you must capitalize consistently.

HelloWorldApp is not the same as Helloworldapp.

This case sensitivity reflects Java’s heritage as an outgrowth of C and C++.

Mark R
+8  A: 

I read Java is case sensitive.. I am not confirmed..

Java source code is case sensitive, if you mean that. i.e. Double is not the same type as double, and you can have two different and separate variables myData and mydata.

If it is case sensitive then what is the specific reason it has been made case sensitive?

Case sensitivity is the norm in most programming languages and environments, because lower and upper case letters are represented differently at the lowest levels. To a computer, "a" and "A" are two completely different things, and it takes extra work to make it act as if they were the same.

Furthermore, some languages have very tricky special rules for casing, e.g. the German letter ß has no uppercase version and is typically uppercased to "SS" - so should "weiß" and "WEISS" be considered syntactially identical? Even worse is Turkish: they have two separate letters i with and without a dot, and each has its own uppercase version. So in Turkey, "IMAGE" is not the uppercase version of "image"! And this is not irrelevant at all, especially for Java, since you can actually use all these letters as identifiers in your Java programs if you want.

In the light of all this, it's very understandable that programming language designers would choose the simple solution of having the syntax be case sensitive.

Michael Borgwardt