/**
- 內(nèi)部類
- @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 自動生成的構(gòu)造函數(shù)存根
formName = s;
}
public void ShowCowMes() {
RedRow redRow = new RedRow("奶牛", 5000);
redRow.speak();
}
class RedRow{//這里就是內(nèi)部類
String cowName;
double Price;
//構(gòu)造方法
public RedRow(String cowName,double Price) {
// TODO 自動生成的構(gòu)造函數(shù)存根
this.cowName = cowName;
this.Price = Price;
}
void speak(){
System.out.println("說話一下"+this.cowName+"值"+this.Price);
}
}
}