java - Reference to Self in Static Initializer -


I have a problem with the three classes in the Java program, I am using public static last I have a constant type of reference in the same class type, but in these sections, the public static final is itself a reference, and ultimately indicates back in the undefined class (leading to a null). . I am using a strategy that uses static references as constants, but it is a strange chaining behavior, if this problem can not be fixed, then what are the options, and what exactly is the problem Can also be fixed?

code:

  public square fu {public static final fu UNKNOWN_FOO = new fu (bar. UNNNIBAR); Private last time; Public fu (repeatedly) {this.bar = bar; }} Public Class Bar {Public Static Final Bar UNKNOWN_BAR = New Bar (Falcon. UNNAABAZ); Private finals falcon falcon; Public bar (falcon falcon) {this.baz = baz; }} Public Sector Buzz {Public Stable Last Falcon UNKNOWN_BAZ = New Falcon (Foo.UNKNOWN_FOO); Private Final Fu Fu; Public falcon (Fu Fu) {this.foo = foo; }}  

As Aaron mentions, try to avoid circular dependence. The following web pages describe the best practices of Google guice for how to avoid and resolve circular dependencies:


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -