java - When trying to print out a constructor, I get the constructor name and a time stamp -


my name chris! improve java programming skills, i'm trying make deck class array of cards, when printing constructor deck class, constructor name , time stamp , clueless why is.

can help?

public static void main(string args[]) {     system.out.println("custom java card game- chris l.");     system.out.println();        deck deck = new deck();   deck.addcards();   system.out.println();   system.out.println(deck); } 

that code main program , here deck class:

 public deck() //deck array of cards   {     size = 52;     cards = new card[size]; //array of cards 52    //   addcards();   }    public void addcards(){   for(int k = 0; k < slength; k++){         (int m = 0; m < rlength; m++){          string s =  suite[k];         string n =  num[m];         int r = rank[m];          string str = integer.tostring(r);    //       string fin = "[" + s + "," + n + "," + str + "] \r";     //      system.out.print(fin);         card card0 = new card(s,n,r); //makes card! working!             turntostring(card0);        //   system.out.println( turntostring(card0) );             cards[k] = card0;   //adds card array! working!         //  system.out.println(cards); //card0            system.out.println(turntostring(card0));         }     } 

and here output:

deck.deck@1f01b29 

can explain me why is?

you must override tostring() method in deck class, otherwise default method object used, doesn't print useful text. perhaps this:

@override public string tostring() {     return "the text want print"; } 

you might want return values of attributes in class, or other information deem useful.


Popular posts from this blog