0

I have this class in Java:

class Vis{
    private char tv;
    public Vis(char tv){
        this.tv = tv;
    }
}

and when I try to initialise this class, I did this:

Vis vv = new Vis('a');
System.out.println(vv);

But what I have is: Vis@74a14482 instead of a. Can I ask what have I done wrong? Thanks

Anda Zhao
  • 51
  • 1
  • 9

1 Answers1

1

If you would like to have a custom value printed, then you need to override the toString method of your Vis class.

Take a look here for more information.

Community
  • 1
  • 1
smaili
  • 1,245
  • 9
  • 18