So I designed this class in Java and am trying to test it. When I run the test file, it prints a memory address instead of the actual name. Any ideas?
Here is the class:
public class Card{
private String name;
public Card() {
name = " ";
}
public Card(String n) {
name = n;
}
public String getName() {
return name;
}
public boolean isExpired() {
return false;
}
public String format() {
return "Card holder: " + name;
}
}
Here is the test file:
import java.io.IOException;
public class Lab12Test {
public static void main (String [] args) throws IOException {
Card q = new Card("John");
System.out.println("Card Class: " + "\n");
System.out.println(q);
}
}