All,

In the following code snippet, why is it necessary to create a new
String[]?

        // Make a normal 52-card deck
        String[] suit = new String[] {"spades", "hearts", "diamonds",
"clubs"};
        String[] rank = new String[]
 
{"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};


Isn't it possible to assign the array directly to suit & rank
references or am I missing something here?  I'm making the assumption
that I can treat String as a primitive - possibly wrong.

        // Make a normal 52-card deck
        String[] suit = {"spades", "hearts", "diamonds", "clubs"};
        String[] rank =
{"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};

Both assignments appear to work when I run the code.  However, since
I'm striving to become a good Java coder,  which code snippet would be
considered correct.

Kindest regards,
Casey Coppock

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to