import javax.swing.*;
//*********Found********
import java.text.*;
public class Java_3
{
public static void main( String args[] )
{
//*********Found********
SimpleTime t = new SimpleTime ( 12, 30, 19 );
//*********Found********
JOptionPane.showMessageDialog( null, t.buildString(),
"Demonstrating the \"this\" Reference",
//*********Found********
JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 );
}
}
class SimpleTime {
private int hour, minute, second;
public SimpleTime( int hour, int minute, int second )
{
this.hour = hour;
//*********Found********
this.minute = minute;
this.second = second;
}
public String buildString()
{
//*********Found********
return "this.toString(): " +this.toString() +
"\ntoString(): " + toString() +
"\nthis (with implicit toString() call): " +
this;
}
public String toString()
{
DecimalFormat twoDigits = new DecimalFormat( "00" );
return twoDigits.format( this.hour ) + ":" +
twoDigits.format( this.minute ) + ":" +
twoDigits.format( this.second );
}
}
这是java中那个内容的?为什么这么写?
黄沛元
相关分类