Java - output not printing properly -


this question has answer here:

how can improve on code such not produce hash values when call print method? reckon @2a.... etc behind card keyword hash values.

my codes produce following output when call method print them out:

run: card.card@2a139a55 card.card@15db9742 card.card@6d06d69c card.card@7852e922  code: public class card {      /**      * @param args command line arguments      */     static string[] rank = {"2","3", "4", "5", "6", "7", "8", "9", "10", "j", "q", "k", "a"};     static string[] suit = {"spades","hearts", "clubs", "diamonds"};      public card(string r, string s)     {       }      public static void init(card[] deck)     {         for(int x = 0; x<deck.length; x++)         {             card newcard = new card(rank[x%13], suit[x/13]);             deck[x] = newcard;         }     }      public static void swap(card[] deck, int a, int b)     {         card temp = deck[a];         deck[a] = deck[b];         deck[b] = temp;     }      public static void shuffle(card[] deck)     {         random rnd = new random();         for(int x = 0; x<deck.length; x++)         {             swap(deck, x, (rnd.nextint(deck.length)));         }     }      public static void print(card[] deck)     {         for(int x = 0; x<deck.length; x++)             system.out.println(deck[x]);     }       public static void main(string[] args) {         // todo code application logic here         card[] deck = new card[52];         init(deck);         print(deck);     } 

you should override tostring() method of class card.

public string tostring() { return "i want print this"; } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -