这是代码,帮看一下吧: private class Rock{ ///private为什么不能放在这里 Rock(int i){ //This is the constructor System.out.println("Creating Rock"); } }public class SimpleConstructor{ public static void main(String[] args){ for (int i = 0; i < 10; i++) new Rock(); } }
你这样写就对了: public class SimpleConstructor{ public static void main(String[] args){ for (int i = 0; i < 10; i++) new Rock(); } private class Rock{ Rock(int i){ System.out.println("Creating Rock"); } }}
public class SimpleConstructor{ public static void main(String[] args){ for (int i = 0; i < 10; i++) new Rock(); } private class Rock{ ///private为什么不能放在这里 Rock(int i){ //This is the constructor System.out.println("Creating Rock"); } } }
private class Rock{ ///private为什么不能放在这里
Rock(int i){ //This is the constructor
System.out.println("Creating Rock");
}
}public class SimpleConstructor{
public static void main(String[] args){
for (int i = 0; i < 10; i++)
new Rock();
}
}
public class SimpleConstructor{
public static void main(String[] args){
for (int i = 0; i < 10; i++)
new Rock();
}
private class Rock{
Rock(int i){
System.out.println("Creating Rock");
}
}}
public static void main(String[] args){
for (int i = 0; i < 10; i++)
new Rock();
} private class Rock{ ///private为什么不能放在这里
Rock(int i){ //This is the constructor
System.out.println("Creating Rock");
}
}
}