首页 > 编程语言 > 详细

java -- 内部类

时间:2017-09-03 01:06:33      阅读:295      评论:0      收藏:0      [点我收藏+]

package sad;


public class ers {

public static void main(String[] args) {
RedCowForm a = new RedCowForm();
RedCowForm b = new RedCowForm("红牛");
b.ShowCow();
}}
class RedCowForm
{
String name;
RedCow cow;
RedCowForm()
{
System.out.println("输入错误");
}
RedCowForm(String s)
{
cow = new RedCow(100,100,200);
name = s;
}
class RedCow
{
int height;
int weight;
int price;
RedCow(int h,int w,int p)
{
height = h;
weight = w;
price = p;
}
void ShowMess()
{
System.out.println("height:"+height+"weight:"+weight+"price:"+price);
}
}
void ShowCow()
{
cow.ShowMess();
}
}

java -- 内部类

原文:http://www.cnblogs.com/2206411193qzb/p/7468514.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!