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

介绍我自己---练习类的创建和使用

时间:2017-10-22 01:30:19      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:todo   font   --   div   sys   log   功能   print   pineapple   

一我要做什么

    介绍我自己并输出到屏幕

二任务步骤
    1定义一个类 属性 姓名, 颜色 ,大小
    功能 使用 ,show自己
    2创建自己并show

 1 class BigPineapple{
 2     String name = "菠萝";
 3     String color = "黄色";
 4     String size = "大";
 5     static void use() {
 6         System.out.print("给海绵宝宝当房子");
 7     }
 8     void show() {
 9         System.out.println("名字:"+size+name);
10         System.out.println("顔色:"+color);
11         System.out.print("作用:");
12         use();
13     }
14 }
15 public class Item {
16 
17     public static void main(String[] args) {
18         // TODO Auto-generated method stub
19         BigPineapple me = new BigPineapple();
20         me.show();
21     }
22 
23 }    
名字:大菠萝
顔色:黄色
作用:给海绵宝宝当房子

停电了......

介绍我自己---练习类的创建和使用

标签:todo   font   --   div   sys   log   功能   print   pineapple   

原文地址:http://www.cnblogs.com/daboluo123/p/7707381.html

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