How can a double quote ("") have a method even if you didn't actually declared it in a String. Like for example:
System.out.println("".length());
is "" an object already without declaring it on a String?
or is it a keyword on Java that he knows it is already a string in the making?
JLS §3.10.5 explains what string literals are ("A string literal consists of zero or more characters enclosed in double quotes.") and also says:
A string literal is always of type String (§4.3.3).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With