Why String is not a primitive data type

Questions by gothlururaaja

Showing Answers 1 - 14 of 14 Answers


  • Jun 24th, 2006

The primitive datatypes are nothing but the basic data types..like int,char,float,double etc..Char is a datatype which stores 2 bits of data..String has been derived from Char which takes more number of Char and integers..providing the more memory storage...Its not a primitive coz it is a basic datatype...Its advancement of char..So its not a primitive datatype

  Was this answer useful?  Yes


  • Jun 27th, 2006

As balaji has asked a nice question that " why double is a primitive data type as it came from float?" As double is the default data type given to the floating point-numbers.Naturally when we declare float f =0;---------the memory occupied to it is double.Inorder to use memory effectively,we go for float as float f=0.0f;As double is not a two float.

  Was this answer useful?  Yes


  • Jun 29th, 2006

There are two types of datatype 1. primitive 2. Object

I think String can also be primitive and Object type.

If u write String a = "rabbi"; then the String will be used as primitive datatype.

But If u write String a = new String("rabbi"); then String will be used by Object datatype.

  Was this answer useful?  Yes


  • Jul 1st, 2006

I think both:

String a= "abc"; and String a = new String("abc");

are the same.

  Was this answer useful?  Yes


  • Jul 2nd, 2006

You r right Suri

Strings are immutable , so
String a = "abc";
is same as
String a = new String("abc");

  Was this answer useful?  Yes

Ananth Murthy

  • Jul 4th, 2006

Float and double both occupy fixed amount of memory irrespective of what number it holds. But String is an object. Memory allocation depends on the content


  • Jul 18th, 2006

The Main reason behind is that when we talk about primitive data type

Lets say for ex int i=5 , it means in memory where we have i , if we will access the contents there we will get the value 5.

But in case of a String , when we say

String s="abe";

when we try to access the contents of s we get the address where we have "abc".


  • Jul 26th, 2006

String is a predefined class and it is not a data type

  Was this answer useful?  Yes


  • Jul 26th, 2006

hi ..

 thank for ur reply

now its clear


keep smiling and mailing

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account

Send   Reset


Related Answered Questions


Related Open Questions