• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding arraycopy() method  RSS feed

 
Pratik D mehta
Ranch Hand
Posts: 121
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

//My question is why cant we write in code
//System.arraycopy(s1.arr1[],0,s1.arr2[],0,10);--why this dosent work
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because it is not:
System.arraycopy(s1.arr1[],0,s1.arr2[],0,10);
But
System.arraycopy(s1.arr1,0,s1.arr2,0,10);
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's kind of a circular answer.

In any case, foo[] isn't a valid expression; it's a type. You can have a *reference* to a foo[], but the reference won't include the brackets. You can refer to a *member* of a foo[], but then you need an index, like foo[0]. So the bottom line is that it's syntactically invalid.
 
Pratik D mehta
Ranch Hand
Posts: 121
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you David and Wouter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!