I would like to implement selection sort using LinkedList in Java. I know how to do it with ArrayList, please don’t comment that I should use it instead. I am interested in demonstrating the advantages (fast insertion and removal) and disadvantages of linked lists compared to arrays. I know how to do th…
Tag: java
converting string to number inside Jooq select – Oracle
I am using jooq’s DSL.select in my Java code, I have scenario where I need to determine the index from a string. Used DSL.substring(“hello123”,6,1) to get the desired index value as string, but no method supporting in DSL to convert it to a number. Example: the nested substring need to be co…
Thread.sleep behaviour with non-volatile boolean variable
According to the JLS 17 specification section 17.3: For example, in the following (broken) code fragment, assume that this.done is a non-volatile boolean field: The compiler is free to read the field this.done just once, and reuse the cached value in each execution of the loop. This would mean that the loop w…
Spring event lifecycle
To understand if the spring events fits the task im working on I need to understand how they work, where are they stored? as I can guess they are stored in a spring application context and disappears if the application crashes, is my guess correct? Answer Spring events are intended to use when calling methods…
How to mock the Keycloak framework methods using Mockito in java
I’m the having functionality to fetch the following details from KeyCloak. User details Realm details Client details I want to write the test cases for those functionalities using Mockito. below is code logic for fetching those details. I want to mock the KeyCloak methods in my test cases for example I …
Removal of usage-links in IntelliJ
While changing PCs I downloaded the latest version of IntelliJ (2022.1.2 Build #IU-221.5787.30) and I can now see usage links for all fields, methods and such in my code. It does seem to work as it is supposed to, but I find that it takes up too much space and would like to turn it off. I am yet to
Java streams – Get max two objects depending on condition
Relatively new to java streams and I have encountered an issue which I could not find a solution for. I have A list of 10 objects and filtered them to return 4 objects. this returns 4 objects: So basically what I am trying to do is take stages that have the same value of stageToCalc and find the maximium stag…
How to pars inner XML Tags with SAX
I am trying to read data from an XML file by using SAX. But i cant figure out how to handle the inner <Path> Tag… How to do pars the inner path element? This is my XML file. Here the neccessary java code snippets. I dont feel like adding the following code is the right approach at all … I
AES Encryption algorithms and padding scheme
Hello currently i have to do an AES encription and send it to an external SW but i am having trouble with the sonarqube. this is the relevant part of my current code: Is a little spaguetti cause it´s recyclated for an old code (TripleDES) sorry for that. But we can get the gist of it that`s that we are
how can I use backslash to backreference regex groups in java replaceAll()
for example: this Java code will switch the place of ‘1’ and ’14’. but The form that i want is below, unfortunately Java not supported this form Is there any other tool can support this form? Answer You can’t do that. And although it is not processed as back references by the reg…