Can a primitive value be considered an object in java? -


when started out using java, implied me have 2 different types:

objects (strings, classes, println, etc) primitive values (int, double, char) 

i got exam professor difference mean difference between 2 choices answers. when asked professor clarify, told me primitive values can objects.

who right here , can give me proof? proof official sounding , choose answer awarding proverbial internets.

can primitive value considered object?

the answer no.

the jls states

there two kinds of types in java programming language: primitive types (§4.2) , reference types (§4.3). there are, correspondingly, two kinds of data values can stored in variables, passed arguments, returned methods, , operated on: primitive values (§4.2) , reference values (§4.3).

those primitive types , values are

predefined java programming language , named reserved keyword

and reference types , values can 1 of

class types (§8), interface types (§9), type variables (§4.4), , array types (§10).

note there special type the null type , corresponding value the null reference

there special null type, type of expression null (§3.10.7, §15.8.1), has no name.

...

the null reference possible value of expression of null type.

for primitive types jls has defined mechanism called boxing conversion converting them corresponding reference types.

boxing conversion converts expressions of primitive type corresponding expressions of reference type.

so since there need conversion go primitive type corresponding reference type 1 cannot primitives can considered objects , vice versa. 1 can convertible.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -