/**
- 内部类
- @author BO
*/
public class InnerClass {
public static void main(String[] args) {
RedCowForm redCowForm = new RedCowForm("母牛代工厂");
redCowForm.ShowCowMes();
}
}
class RedCowForm{
static String formName;
public RedCowForm(String s) {
// TODO 自动生成的构造函数存根
formName = s;
}
public void ShowCowMes() {
RedRow redRow = new RedRow("奶牛", 5000);
redRow.speak();
}
class RedRow{//这里就是内部类
String cowName;
double Price;
//构造方法
public RedRow(String cowName,double Price) {
// TODO 自动生成的构造函数存根
this.cowName = cowName;
this.Price = Price;
}
void speak(){
System.out.println("说话一下"+this.cowName+"值"+this.Price);
}
}
}