Skip to content

Tag: java

Which import should be considered?

Consider the following code snippet. This code compiles well with Java 11 even though I thought it should not. Observable is also a java class in java.util and I do not understand how the compiler knows whether to use Observable from java.util or my custom package rx. Note that java.util.Observable was deprec…

Log4j ThreadContext.clear() not available with auto-complete?

according to the Log4j documentation I can call ThreadContext.clear(); but in my IDE I do not get clear() as an available method and I also get compilation errors, I only see clearAll(), etc., why? What is missing on the classpath? Log4j Version 2.16.0 is used. Answer As per https://svn.apache.org/viewvc?view…

When to use Functional Interface vs Function

I am using Java 11, and we have two ways of passing in functions as an argument. functional interface Function<T, Y> Now I am not able to find anything on when to use which one. I can figure that we can use a generic functional interface over a Function<T,Y> when we either don’t want to pass…

How to make an app using swing that only uses 1 JFrame?

I am making an app or (something.exe). I want to make a class that will serve as my main frame. That is because I don’t want to create new frame for each class that I will make. I want my class MainMenu to have the Frame of MainFrame where I can put buttons and etc. Answer Make use of Model-view-control…