⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 java_3.java

📁 JAVA学习源代码,大家可以好好参考,请多提宝贵意见
💻 JAVA
字号:
 //*********Found********
import javax.swing.*;
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 );
   }
}
/* JOptionPane类的常用静态方法如下:
   showInputDialog()
   showConfirmDialog()
   showMessageDialog()
   showOptionDialog()
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -