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中那個(gè)內(nèi)容的?為什么這么寫(xiě)?
添加回答
舉報(bào)
0/150
提交
取消