Hello everyone, I'm a little stuck here.
What am I doing wrong?
com/codegym/task/task06/task0603/Solution.java:11: error: non-static variable this cannot be referenced from a static context
Cat cat = new Cat();
^
com/codegym/task/task06/task0603/Solution.java:12: error: non-static variable this cannot be referenced from a static context
Dog dog = new Dog();// write your code here
^
package com.codegym.task.task06.task0603;
/*
Cat and Dog objects: 50,000 each
*/
public class Solution {
public static void main(String[] args) {
for(int i=1; i<=50000; i++){
Cat cat = new Cat();
Dog dog = new Dog();// write your code here
}
}
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");
}
}
}