Ask Your Question
3

What is the distinction between Object and Object[] when it comes to arrays reference variable?

asked 2021-05-09 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-12-31 16:00:00 +0000

bukephalos gravatar image

In Java, Object refers to a single object, whereas Object[] is an array of objects.

An Object reference variable can point to any object type, including primitive wrappers, user-defined classes, or even null. However, it can only refer to a single object at a time.

On the other hand, an Object[] reference variable can point to an array of any object type, including primitive wrappers, user-defined classes, or even null. It can refer to multiple objects at once, and each element in the array is an Object reference.

In essence, Object is used for referencing a single object, whereas Object[] is used for referencing an array of objects.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-09 11:00:00 +0000

Seen: 7 times

Last updated: Dec 31 '21