This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another question regarding arrays

 
Ben Buchli
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

is

int[] newArray = arrayReferencePassedAsMethodParameter.clone();

equals to copying the returned array into a new array? I mean, do I make sure that I dont refer to the reference that could be modified somewhere else?

Thanks in advance,
Ben
 
Hari Gangadharan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep. It is safe as long as it is an array of primitive datatypes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic