0

sorry I'm new to java so hopefully my terminology is fine. I'm trying to make a hangman game, in my constructor I have

   `System.out.println("\f==========|");
    System.out.println("| |       |");
    System.out.println("| |");
    System.out.println("| |");
    System.out.println("| |");
    System.out.println("| | __");
    System.out.println("| |___|");`

but when it prints out the object in my main class, it prints out this:

picture of output

I don't want to have the memory address, just the gallows. In my main class, I have for this

 public void gallows ()
{
    Gallows gallow = new Gallows(wrongGuesses);
    System.out.println(gallow);
}

and then in a different method that prints I have

gallows();

Any advice?

  • I think that you do not need this print method: System.out.println(gallow); Because you already print your gallows inside your constructor. Remove this line and see if it works. You can also try to use toString() method. If it does not, post your complete code so i can help :) – Gabriel Mesquita Apr 28 '17 at 00:43
  • 1
    Removing that line fixed it, thank you! (I also feel rather silly for it being such a simple solution) – user7934205 Apr 28 '17 at 00:49
  • No problem :) go on and give a thumbs up haha – Gabriel Mesquita Apr 28 '17 at 00:52
  • No memory address was "printed out". The value you see is a notation that combines information about the type with the hash code of the instance, not a memory address. – Lew Bloch Apr 28 '17 at 01:52

0 Answers0