Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Java case-sensitive? [closed]

I read somewhere that Java is case-sensitive. I have been unable to confirm this. Is it? If so, why?

like image 589
giri Avatar asked Jan 24 '10 19:01

giri


People also ask

Is Java case sensitive yes or no?

Java is one of the widely used programming languages. Java is a case-sensitive language, which means in code showData and showdata are two different variables.

Is Java a case sensitive language justify your answer?

Yes, it is case-sensitive. It is this way because of its heritage 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.

How do you handle case sensitive in Java?

The equalsIgnoreCase() method compares two strings, ignoring lower case and upper case differences. This method returns true if the strings are equal, and false if not. Tip: Use the compareToIgnoreCase() method to compare two strings lexicographically, ignoring case differences.

Is Java and C++ is case sensitive?

You can name classes with uppercase, such as Vehicle, Tree, and Game. Java is based on programming languages like C++ and C, but all the programming languages are not case sensitive. Languages that don't enforce case-sensitivity are COBOL, FORTRAN, Pascal, and other primary languages.


1 Answers

I read somewhere that Java is case-sensitive. I have been unable to confirm this.

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.

Is it? If so, why?

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.

like image 81
Michael Borgwardt Avatar answered Nov 15 '22 20:11

Michael Borgwardt