• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array overwritten  RSS feed

 
Ranch Hand
Posts: 101
  • 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?
 
Ranch Hand
Posts: 192
  • 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.

 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!