Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reference

 
Divakar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between int[] a; and int a[];
a)No difference.
b)First one will give compilation error.
c)Second one will give compilation error.
d)First one represents array of int references.
e)Second one represents array of int references.
f)both represents array of int elements.
What is the answer??
My answers- a,d,e
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(a)
and
(f)
are TRUE, IMO.
 
Arijit Ghosh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the differenc between array of int references and array of int elements ?
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arijit:
What is the differenc between array of int references and array of int elements ?

I don't understand the question. Can you give a specfic example?
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean the difference between int[] and Integer[] ?
The first is an array of (primitive) ints, while the second is an array of references to Integer objects (wrappers for ints).
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ints are primitives and in Java primitives never have references.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Divakar,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
PS: Quote from the naming policy:

For your publicly displayed name, use a first name, a space, and a last name. Obviously fictitious names or improperly formatted names may be locked out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic