Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

Is String a Primitive datatype or Non-Primitive? (Since String is an Object)

I know String is a Primitive data type, but it can also be an Object.
If it's an Object, how can it be Primitive?


String s1="hello";
String s2=new string ("hello");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER


i is still an Integer Object, but Java has just done this behind the scenes..
Integer i = new Integer(3);


Is integer an object?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

could you give an example of a wrapper
could you give an example of a wrapper
Wow, an example was in that last post from it_saige... "While int is a primitive, Integer wraps the value of the primitive type int in an object"

The others are...  Long, Short, Double, Float, Character, Boolean and Byte
Avatar of rgb192

ASKER

thanks for int string wrapper