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…
Tag: java
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…
Java Generics – Type must be from Class T “or” extend S
I am developing a ComboBox (more for context than actual significance), and I would like to know if the “or” operator exists in Java generics. For now, the declaration looks something like that: Where ComboBoxItem is an interface I created for items that can be used in the ComboBox. However, IR…
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…
Use Class as a method signature
In the method signature, I need a parameter that is any class type that extends from Collection (List, Set, etc), so I can return any of them. To try to achieve this I did use the following method: However when I try to use it like: The following error arises: I did search for an answer already solved in Stac…
Does a response containing multiple json Values always have to be wrapped in an array in java?
I am trying to return a response from the back end using java where the response is a list of json values. Is it possible to return the data in this format? I noticed that json values are always returned wrapped in an array like this I was asked to return the json data without being in an array and
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…
Confused about session management between Apache httpd and Tomcat using mod_jk
I am confused about session management between Apache httpd and Tomcat using mod_jk. I know that Apache is typically used for serving http pages, and Tomcat is used as instructions for handling different types of web requests. So when an application using both of these receives a request, does Apache create a…
Replace @PathVariable object with ID only for Springdoc
I am currently trying to migrate from Springfox to Springdoc. Most of my endpoints contain a @PathVariable Instance. Obviously I am only passing in the ID of the instance and Spring would automatically resolve the object for me. Here is an example: Called as /api/myInstance/role. Springfox would handle this c…
How to get id data from database deleting – setOnLongClickListener ERROR
I have a recyclerview and sql lite database. I keep city names in SQLite database and display them in recyclerview. When the city is setOnclickListener in the recyclerview, the city’s weather is shown and I do this by taking the city’s id from the sql lite database. arrayList.get(position).id it w…