I am new to Java, and I’m trying to figure out how to count Characters in the given string and threat a combination of two characters “eu” as a single character, and still count all other characters as one character. And I want to do that using recursion. Consider the following example. Input: Desired output: Current output: I’ve been trying
The program cannot do compareTo function after the object’s update information
I am trying to change the position of the product in the print menu after updating some information of the product. Specifically, arrange “Quantity” in descending order. If the products have same quantity, the list will be sorted with the ascending “UnitPrice” field. Initially, if i add one more product, compareTo() function works fine, but after i use product update
Add more element to a 3×3 2D array
I’m writing an inventory list program, that provides the user with option of adding an item to the list of exiting the program. To add an item the user enters 1 and is promoted to enter the item details( item name, price and quantity of the items). The information enter by the user is entered into a 3×3 2D array
Application not compatible with older Android versions
I’m generating an Android application via mvn -Pandroid gluonfx:build gluonfx:package. Here are the versions from the POM: Using graalvm-svm-java17-linux-gluon-22.1.0.1-Final The application works well on Android 8. However, when trying to install it on Android 7.0, a message pops up saying that the application is not compatible with the device. I’m not sure where the default version is specified, but following
Build war files for services when modules are modified
I have a monorepo with the following structure: My end goal here is to deploy the application’s war files to aws via GitHub actions. I am able to deploy individual services whenever there are changes in them, with the command mvn clean install -Dmaven.clean.failOnError=false -f services/foo/pom.xml. However, I am not sure how to update the services whenever a module it
Locking execution within CompletableFuture
I need to post-process result of CompletableFuture.supplyAsync execution to get intermediate result. My code looks following In a result I’m facing with java.util.concurrent.CompletionException: java.lang.IllegalMonitorStateException on .thenAccept(resultPerBatch -> { line Seems like I’m using lock in wrong way but I cannot figure out how to avoid this kind of exception. Answer There’s no guarantee that the Function passed to thenApply and
Containerizing executables in Java
I have a CEF (Chromium Embedded Framework) application I am controlling with Selenium. Normally the application does not allow multiple instances of it to be running at the same time since it modifies directly its root files. I need to be able to run multiple instances (controlled by Selenium) though and some kind of containerization is therefore needed, correct? I’ve
How can I unit-test Exception thrown inside a Lambda?
I have a method: This is how the user authorization test looks like: Is there any way to check the case when a user has entered the wrong password? In the case when I send the wrong password, it doesn’t work because given(this.repository.findByEmail(this.user.getEmail())).willReturn(Optional.of(this.user)); makes repository.findByEmail() return the result before you get to checking the password. Answer You don’t need this
Search in List of X509CRL’s
I have a list of X509 CRL’s. I need to identify some of them somehow. Right now I do it using issuer: But there’s gotta be a better way to do that using knowledge of CRL file format, maybe with comparing public keys or something like that, but I don’t know much about X509CRL’s. Can someone help me out? Answer
How to make a parameter override while running a Java jar file?
I have a Java maven project whose Jar file is used as a SDK library in other projects. This SDK is used to call other APIs which are by default in the prod environment. I want to make it run on testing environment by overriding a variable. This is the Routes class which contains the base URL for prod/testing is