Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes String object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "String object" Watch "String object" New topic
Author

String object

Bhayajis Bhayajis
Greenhorn

Joined: Sep 29, 2003
Posts: 9
Is there any valid reason why byte, long, float, double, int, short and char are primitive types and not String (which is an object)
Tom Wolve
Ranch Hand

Joined: Sep 22, 2003
Posts: 32
Convenience is a reason maybe not a valid one.
I prefer writing (and reading) instead of
[ October 16, 2003: Message edited by: Tom Wolve ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Shouldn't the question in an Object Oriented language be "Is there any valid reason why byte, long, float, double, int, short and char are primitive types?"
but back to your question, if String was a primitive, it wouldn't be able to have any methods ( because primitives can't have methods! ). So if you remove all the methods, and supporting class functionality, what are you left with?
char[] ! which is a primitive array!
actually, I don't think that's the real reason, but I digress
Jamie
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: String object
 
Similar Threads
what is string an object or literal ?
String - immutable
about Constructor overloading
StringTokenizer question
proper Collection for my needs