Don’t assign static references to instance method calls in Java

Patrick Brown
3 min readJan 28, 2019
Photo by Luca Bravo on Unsplash

Assigning a static reference to an instance method call could be perilous. Let’s take a look at an example Java class to examine why:

/**
* Foo.java
*/

public class Foo {
public static String foo = Config.getInstance().getFoo();
}

Seems pretty innocuous in itself, but ostensibly we’re just assigning static reference in Foo

--

--