I have seen various approaches to defining a static array in Java. Or:
String[] suit = new String[] { "spades", "hearts", "diamonds", "clubs" };
... or only
String[] suit = { "spades", "hearts", "diamonds", "clubs" };
or as List
List suit = Arrays.asList( "spades", "hearts", "diamonds", "clubs" );
Is there any difference (other than defining a list, of course)?
What is the best way (performance)?
java arrays static playing-cards
Jeremy S. Aug 08 2018-11-11T00: 00Z
source share