• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

I have a bug with NeatBeans also in Visual Code, I don't what i'm doing wrong

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing goes like this: after choosing the position of your ship, the game starts showing you a grid of gray squares in which you should be able to click on the gray squares and hit or turn the squares white and the top table will show your ships, but the The error only occurs when I have the classes inside packages or I don't know what happens, because when I run the classes together without being in a package and placing a fixed file path, the program works correctly. I'm not quite sure.

Thanks everyone

That's my code
[Thumbnail for image_2023-11-20_222254493.png]
[Thumbnail for image_2023-11-13_200213693.png]
Ranch Hand
Posts: 202
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's quite hard to say what happened when you don't include the error message(s) you got  when running the code with explicit package declarations.

It's hard to guess what went wrong - especially when the link in Google Drive is not readable. When you have an error related to  package definition it may be that the source code is not placed into directories according to the package name.

Here I am using plain javac and java - in real life a build tool such as Maven should be used, but that's another story.

Code for class A in package com.example should the be put into the directory :

Then you can compile:

... and execute the class:

Posts: 78698
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Juan Hidalgo wrote:. . .. . .

Just like RM, I am unable to compile your code because some is missing. I can see some errors however. For example, the above is not a default constructor. I don't know whether it is a good idea to overload the constructor name like that.
I think you are wrong to use an Object[][] and cast its elements when you could use a ShipPiece[][] instead. It is also a bad idea to pass a reference to an array without taking a defensive copy.
I don't think the boolean called isTurn is the correct way to handle alternating players. And why is it volatile?
What's gotten into you? Could it be this tiny ad?
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic