public class Solution {
public static void main(String[] args) {
for (int x = 0; x<=50000; x++){
Cat cat = new Cat();
Dog dog = new Dog();
}
}
}
class Cat {
@Override
protected void finalize() throws Throwable {
super.finalize();
System.out.println("A Cat was destroyed");
}
}
class Dog {
@Override
protected void finalize() throws Throwable {
super.finalize();
System.out.println("A Dog was destroyed");
}
}
Someone know why it Does not work?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
krystian
8 January 2020, 06:16
Thanks ! It works!
I have forgotten that it starts from 0, not from 1.
0
Anthony Chalk
7 January 2020, 21:10
Write
x<50000
instead of
x<=50000
0