public class Solution {
public static void main(String[] args) {
// 在此编写你的代码
int num = 50000;
for (int a = 0; a < num; a++) {
Cat cat = new Cat();
Dog dog = new Dog();
}
}
}
class Cat {
@Override
protected void finalize() throws Throwable {
super.finalize();
System.out.println("一个 Cat 被销毁");
}
}
class Dog {
@Override
protected void finalize() throws Throwable {
super.finalize();
System.out.println("一个 Dog 被销毁");
}
}
Create 50000 Cat objects and 50000 Dog objects. Did I make it right or not? I felt the methods that I wrote were strange and I can't tell why.
已解决
评论 (2)
- 受欢迎
- 新
- 旧
你必须先登录才能发表评论
云鶴 黄
9 六月 2021, 00:59
0
楊宗翰
18 七月 2020, 06:45
I think your code is right .
0