Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

java question :- To create an array we would first or any object we have to allocate memory to it . Boy b = new Boy() Why isn't this required for primitive datatypes like int, float or double after all they are objects too

OpenStudy (anonymous):

Say can I do something like Integer a = new Integer();

OpenStudy (anonymous):

primitive data types are not objects !! "int" is primitive data type but "Integer" is not primitive data type rather "Integer" is a Wrapper class for primitive data type "int".

OpenStudy (anonymous):

beacuse that since they are all classes that already exist in standard lib of java....

OpenStudy (anonymous):

we have primitive types which are wrapped by classes called wrapper classes... so while when we call int, wrapper classes are used i hope....

OpenStudy (anonymous):

int, float, double and all primitive data types, their memory size is well known by your compiler and if you want predefined by you machine architecture. But for an array for example, your computer can't know what's the size that the user needs, 10, 30, 150, or what?!! For that, it's let to by defined by the user depending on his needs.

OpenStudy (anonymous):

yeah primitive data types have predefined memory size and can have a short habd declaration u can use the long hand representation too and it jus works fine but coming to the complex data types like say string which is typically a continuous array.............u donno the predefined size....

OpenStudy (anonymous):

Thanks for the input guys .

OpenStudy (anonymous):

You're welcome.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!