hi sir, i hope u r doin' fine.i have an question about string.In javastring is taken as object rather than data type.in other languages it is taken as data type.why it is so in java. i hope you will help me to solve it.take care. with regards kumar abhay
Well, in C++, they mask String's so that they almost have the appearance of primitives, however this is not the case. They fully appear as objects in Java, because, unless you use string literals, you actually have to use the String constructor. As far as I know, you can't have Strings as a primitive. ------------------ Michael J Bruesch Codito, ergo sum... I code, therefore I am. http://www.geocities.com/mjbruesch
Michael J Bruesch<br /><i>I code, therefore I am.</i>
Hi there u had a good Questuion There ... and i think u will not be convinced by above replies ... i will try to sort u out from there ...
in java String is a class that has particular specifictaions ... and more Strings as n C++/c are char arrays ... which are ccreated by combining different chars ...
for example in c string is represnted as 'a','s','t','r','i','n','g' but in java u have simply String a = "astring"; and that is all ... now the memory allocated will be of totalbytes in a string
Joined: Sep 23, 2001
yes, that is exactly why they're not primitives. The lowest form you can break sentences down to is single letters (aka: chars). If you want to form complete sentences or thoughts, you must combine multiple letters (aka chars) together. There is no way no make this into a primitive form seeing as how there are literally infinite ways of putting separate chars together. Therefore, it must be made into a class where the user decides on the order in which the chars be put together. Hence...Strings. ------------------ Michael J Bruesch Codito, ergo sum... I code, therefore I am. My Java Games, I'm quite proud
(Marilyn fixed url) [This message has been edited by Marilyn deQueiroz (edited October 26, 2001).]