+ 1

Does string in java terminate with NULL and does it occupy any space? What will be length of the string "HELLO" ?

Questions on string

10th Jan 2017, 6:00 AM
Nabajyoti Kumar Das
Nabajyoti Kumar Das - avatar
2 Respostas
+ 2
strings are refrence type that means string variables store refrences to string objects in the heap...if you assign null to a string variable, string object that it refered become condidate for terminating(collecting) by GC(garbage collector)..you can think strings as array of characters thus HELLO length = 5...(sorry,english is not my first language)...
10th Jan 2017, 6:17 AM
Masoud Farmani
Masoud Farmani - avatar
+ 1
stirng in java is an object, but still in deep level it dose use '\0' char to teriminate the string, and yes it dose take space... but in most cases you dont need to worry about that...
10th Jan 2017, 6:32 AM
Tamilselvan D
Tamilselvan D - avatar