62,614
社区成员
发帖
与我相关
我的任务
分享
package zhao;
public class Book{
/**
* @param args
*/
class Rock {
Rock() {
System.out.println("creating rock");
}
}
public static void main(String[] args) {
//实例化一个外部类,
Book b = new Book();
for (int i = 0; i < 10; i++) {
b.new Rock();//因为你这是类内部类,所以必须一个外部类引用只想这!
}
}
}
new Book().new Rock();
public class Book {
/**
* @param args
*/
class Rock {
Rock() {
System.out.println("creating rock");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Book b = new Book();
for (int i = 0; i < 10; i++) {
b.new Rock();
}
}
}
public class Test{
static class Rock
{
public Rock(){
System.out.println("creat rock");
}
}
public static void main(String[] args)
{
for(int i=0;i<9;i++){
new Rock();
}
System.out.println("Hello World!");
}
}