码迷,mamicode.com
首页 > 其他好文 > 详细

封装类-时钟

时间:2016-05-17 08:33:39      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

 1 package com.hanqi.z1p1;
 2 
 3 public class TestClass {
 4 
 5     public static void main(String[] args) {
 6         // TODO 自动生成的方法存根
 7 
 8         Clock cl1=new Clock(12,45,26);
 9         cl1.show();
10         
11         Clock cl2=new Clock(3,23,06);
12         cl2.show();
13         
14         
15     }
16 
17 }
 1 package com.hanqi.z1p1;
 2 
 3 public class Clock {
 4 
 5     int Hour;
 6     int Minute;
 7     int Second;
 8     
 9     Clock(int h,int m,int s)
10     {
11         Hour=h;
12         Minute=m;
13         Second=s;
14     }
15     
16     void show()
17     {
18         System.out.println("当前的时间是:"+Hour+"点"+Minute+"分"+Second+"秒");
19     }
20     
21     
22     
23 }

运行结果:

技术分享

封装类-时钟

标签:

原文地址:http://www.cnblogs.com/miss123/p/5500210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!