The main difference is related to where they stay in the memory, objects are stored in the heap while value type are stored directly in the Stack ...
heap : is an area of memory used for dynamic memory allocation.
stack : is the section of memory that is allocated for automatic variables within functions. Data is stored in stack using the Last In First Out (LIFO) method.
About NSInteger and NSNumber :
NSInteger is nothing more than a synonym for a long integer, while NSNumber is an Objective-C class, a subclass of NSValue to be specific.
Answer from aleroot on Stack Overflowiphone - What is the difference between primitive data type vs an non primitive data type(apple defined data type)? - Stack Overflow
What is the difference between primitive and non-primitive data types? When are both used? Can you use them synonymously?
What is the reasons and the benefit of non-primitive data in Java?
In Java, why is String a non-primitive data type? - Stack Overflow
Videos
The main difference is related to where they stay in the memory, objects are stored in the heap while value type are stored directly in the Stack ...
heap : is an area of memory used for dynamic memory allocation.
stack : is the section of memory that is allocated for automatic variables within functions. Data is stored in stack using the Last In First Out (LIFO) method.
About NSInteger and NSNumber :
NSInteger is nothing more than a synonym for a long integer, while NSNumber is an Objective-C class, a subclass of NSValue to be specific.
object is : member data + function operating on the data
so, primitive data type is just data, no method directly related to it.
object is something like a module, include the data and function (method here).
NSInteger is primitive data type. NSNumber is object, it's member data maybe NSInteger.
I am new to javascript and still cannot understand the difference.
Thanks!
I am new to Java and I dont get the reason behide non primitive data type that is created by a programmer e.g. School student, in this case School is non-primitive data .
Whats the point of this and how is it useful?
Please enlighten me
Thank you for answering
String is non-primitive because only class can have methods. Primitive can not. And String need many functions to be called upon while processing like substring, indexof, equals, touppercase. It would not have been possible without making it class.
Also class has made it possible to make strings immutable and final to enhance security and efficiency by allowing pooling.
The String Javadoc clearly indicates that String is a subclass of Object; and further String.equals(Object) overrides Object.equals(Object).
JLS-3.10.5. String Literals specifies that
A string literal consists of zero or more characters enclosed in double quotes.
Also, JLS-4.3.3. The Class String adds
Instances of class String represent sequences of Unicode code points.
A String object has a constant (unchanging) value.
String literals (§3.10.5) are references to instances of class String.
The string concatenation operator + (§15.18.1) implicitly creates a new String object when the result is not a compile-time constant expression (§15.28).
It's also worth pointing out that arrays are also Object(s), and An Array of Characters is Not a String. Finally, if a String wasn't an Object it couldn't be null.