How can i resolve "non-static variable HOBBY cannot be referenced from a static context"
package com.codegym.task.task13.task1305;
/*
Four mistakes
*/
public class Solution {
public static void main(String[] args) {
System.out.println(Dream.HOBBY.toString());
System.out.println(new Hobby().toString());
}
interface Desire {
}
public class Dream {
public Hobby HOBBY = new Hobby();
}
public static class Hobby extends Dream implements Desire {
static int INDEX = 1;
@Override
public String toString() {
INDEX++;
return "" + INDEX;
}
}
}