/* Author : Michael Robinson Program : noToStringMethodDemo.java Purpose : Learning to use the toString java method using this noToStringMethodDemo constructor Updated : August 18, 2099 */ public class noToStringMethodDemo { private int day; private int month; private int year; public noToStringMethodDemo( int myDay, int myMonth, int myYear ) { day = myDay; month = myMonth; year = myYear; //when using the 'this' command (references the current object) it calls the toSring method System.out.println( "\nData received by the " + "noToStringMethodDemo constructor: " + this ); }//end public theToStringDemoClass( int d, int m, int y ) /* If the toString method is not declared in the class that is using the 'this' * command to print, java will NOT give an error but it will print the name of * the class and its address */ public String NoToString() { //the return can be any format you need return String.format( "%d/%d/%d", day, month, year ); }//end public String NoToString() }//end public class noToStringMethodDemo