Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array overwritten

 
Rob Brew
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.


I'm building a version of battleships, two arrays are created, x and y, when added to the array list Ships. When i run the program i get the same variables appearing in each instance of the array. Any ideas?
 
Ryan Beckett
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The member x of each instance of Ship refers to same array instance created in init(). It's the same for y. You need to create a new ones.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic