Skip to content

Tag: list

How to call a method and run it asynchronously?

Is there a way to run getUsers() asynchronously only from main() in Java 8? Running getUsers() on the main thread would take 300 seconds. I wish to make it in less than 180 seconds with 4 cores. Without modifying getUsers() (the objective), running the following is still taking 300 seconds: Answer You can div…

Adding an element to the end of a List in java

I have this array that I converted into a list: How would I go about adding a character to the end of the list since there isn’t a specific add function for Lists? Edit: Both my classes and code Answer you have an array of String and convert it to List of String so you cannot add a char to

How to map Iterable to its DTO?

I have the following repository: PermissionRepository: In my service, I am trying to map Permission entity to PermissionDTO, but as findAll() method returns Iterable<T> (Iterable<T> findAll();), I cannot convert as shown below as I generally use for List<T>. It throws “Cannot resolve m…

how do I split array element into more element [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed last year. Improve this question this is…

List of int array in Java

How do I print the contents of a List that contains a primitive type int object in it? Prefer answers to print this in one line. This is the code I have. This will give me [0,1] but I am looking for {[0,1],[2,3]} Answer The following one-liner can meet your requirement: It uses the positive lookbehind and pos…