I have to make a programm that counts the nodes bigger than their sons without including the leaf nodes for example: This is my approach: But I can’t see the error Answer Assuming info is an int, this could work for you. I haven’t tested the code, so let me know if there are issues.
Extract file name from Java URL (file: and http/https protocol)?
I have various urls like this: These are all valid URLS, and I can convert them to a URL in java without errors: I want to extract the filename from each of the examples above, so I’m left with just: I have tried the following, but this doesn’t work for example b above (which is a valid URL): I can
Using SMOTE on java raises Comparison method violates its general contract
I’m working on a project in java and I need to use Weka’s API. I use Maven to manage dependencies and, in particular, I have the following one: In this version, the SMOTE class is not kept, but I really need it; that’s why I also added in my pom.xml the following dependency: In my Java code, i also try
Are CompletableFutures thread safe? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I have a thread that invokes to separate threads. It passes in the same CompletableFuture to both of those child threads. If .get() was called
javax’s @Valid annotation usage scenario
Is it possible to use @Valid (javax.validation.Valid) in below scenario? Here JsonStringToObjectConvertor is taking in JSON in form of String and mapping it to IncidentModel class. I have defined few validations in IncidentModel in below manner and I want to validate the fields mapped by ObjectMapper in IncidentModel before proceeding further: It does not seem to work in the above
Java program uses wrong locale when jpackaged
I am parsing strings representing German-style numbers (i.e., decimal comma and optional full stop for grouping thousands), e.g., “2.804,13”; this is just done using a DecimalFormat based on my desired Locale: This gives the desired output, e.g., when compiled and run from the command line: However, when I bundle it as a jpackage image (./gradlew jpackageImage using Gradle and the
Should I close the prepared statement passed as parameter?
I am aware that we should not reuse prepared statement or use try-with-resource in java. But what should I do with prepared statement passed as parameter? Should I close it too? For example: Answer The way I see it is as follows: In your code somemethod is not the owner of those prepared statements that were passed to it. It
How to handle Docker-Secrets in application.properties files
How do you inject Docker secrets (files/data from /run/secrets) into the application.properties files? Is it safe to use environment variables? Answer First of all, usage of environment variables for secret data for the application.properties isn’t safe. You have mainly two options when talking about Secrets. If you are using Docker Secrets without Docker Swarm then you can directly load the
Put sin on segment in 3d
i need to put a sin function, or any other function on start of segment in 3d space. Something like that: Example But in 3d space, help me pls, i spent about 4 days for solving it, but did not get result There are 2 points in space at arbitrary positions. I need a sinusoid between these two arbitrary points.
Use another MapStruct mapper only inside an expression clause
I have a mapper that, for a particular attribute of the target class, needs to choose one from a list of objects inside the source object, and map it using a differente mapper class. Simplifying it a lot, the Game class contains a list of Transaction objects, and my GameMapper class looks like this: The thing is, EventMapper gets generated