2 Answers. 2. Your toString() method prints the name of the class of the object: return getClass().getName(); The object is an instance of Card , so its class is Card.class , whose name is Card . You want to print the value of the name field.9 Şub 2014
Read moreWhat does getName () do in Java?
getName. Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String . If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by The Java™ Language Specification .
Read moreWhat is Java explain all the properties of Java?
Java follows the Object Oriented Programming Model; we cannot write a java program without a class therefore java is an Object Oriented programming language. Java implements the Object Oriented concepts like Abstraction,Encapsulation,Inheritance,and Polymorphism .
Read moreHow can I practice Java?
Practice Java with these 9 websites
Read moreWhat is in a class in Java?
A class — in the context of Java — is a template used to create objects and to define object data types and methods . Classes are categories, and objects are items within each category. All class objects should have the basic class properties.
Read moreWhat is in a class in Java?
A class — in the context of Java — is a template used to create objects and to define object data types and methods . Classes are categories, and objects are items within each category. All class objects should have the basic class properties.
Read more