Print Page Print Page

CH12 – Cards Are Immutable

  1. Complete the previous exercises in Chapter 12 if you haven’t already.
  2. Modify the rank and suit variables so that they are final.
private final int rank;
private final int suit;
  1. Compile Card.java and run the CardDriver program.
$ javac Card.java
$ java CardDriver 2 3
1
2
Ace of Hearts
2 of King
false
-1