Skip to content

Tag: java

how to use a list in another class?

I want to create a list, add blocks to it and then use it in a BlockBreakEvent to check if the block is in the list and cancel the event if it’s not. But I can’t seem to create and add things in it any other way than in the actual event itself (which looks to me like it would

JAVA Do/while loop not returning the value

I’m new at stackoverflow and coding. I’m trying to make a method for validating the user input. The user is only allowed to answer, add, show or exit. But I keep getting stuck in the first while loop. I tried to change it to !userChoice.equals.. but it is not working. What am I doing wrong. Answer…

why does my sql table treat 1000 as a middle number?

When I try to sort by a value descending my SQL table does it correctly, but if it sees for example “1000” it always puts it in the middle? for Example: this even happens when I reference it in spigot (I’m using it for a plugin) it outputs it the same way this is how I’m calling it in …

Java: How can I efficiently match 2 classes member values partially?

I have 2 classes (3rd party): one is representing a GET endpoint response, and the second one is representing a PUT endpoint body. My aim is to get the resource current state using the get endpoint, and update it using the put endpoint. It appears that the put class is a subset of the get class. For example: …

How to specify array ([]) type in Swagger

Hi I am trying to autogenerate a class using swagger plugin. One property of this class has to be array, but when I write type: “array” always create a List. This is part of my “yml” file: And this is the property that create: Answer In Java, an array has a fixed length. This is differ…

Is shutdown-hook a good practice?

I have a Service that makes requests via a RestClient. What is the Java best practice between: Opening and closing the connection every time I make a request Opening the connection at class initialization and closing it in a ShutdownHook Something I didn’t think of Answer What is the Java best practice …

Stream non terminal operation + filter + findFirst

I’m trying to understand how the non-terminal streams operations are invoked. This seems clear for me. The first stream is not ended with terminal operation, so it doesn’t invoke the non-terminal operation and nothing is printed. The second one has terminal operation, so all the elements are print…