• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics array  RSS feed

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Could anybody please explain this :
public static final <T> T[] deepCopy(T[] array) { return array.clone(); }

Thanks and regards,
Satya
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is it about that method definition that you don't understand? Is it the generic declaration of <T>?
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mansukhdeep,
I tired to call the function and passed an integer array(int[] a) over there , but its giving exception like argument mismatch

Thanks and regards,
Satya
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generic arguments need to be reference types, not primitives. Try it with an Integer array and see if that makes a difference.

If it doesn't, it would be worth showing us how you're trying to call it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!