Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negative String Length

Tags:

java

string

Can you have a negative string length? If so, is it the same as null?

like image 257
robotchicken99 Avatar asked Feb 19 '11 15:02

robotchicken99


2 Answers

No; the length of a string is 0 (empty string, represented as "") or higher. And an empty string is not the same as null either (in Java it is not called a null string).

To better understand what null means in Java, you could check out these questions:

  • Is null an Object?
  • Is null a Java keyword?
like image 83
Jonik Avatar answered Oct 14 '22 12:10

Jonik


No, never.

length is unsigned number, it can't be negative.

the first question's answer negates the second question's legitimacy.

like image 21
Ken D Avatar answered Oct 14 '22 13:10

Ken D