Skip to content
Advertisement

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 divide your loop of users creation into

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

Create and find highest value in subarraylist

I have an Arraylist of the Cells from an Excel sheet. I want to create subarraylists of size 50 from the Arraylist of Cells I actually have, beginning from the index of 1590 and ending with size()-700. I want to get the highest number from every subarraylist and put it in the new Arraylist. in the new Arraylist there should

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 method ‘stream’ in ‘Iterable'” error for the .stream() method. So, how can I map this Permission entity to

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 my array: and I want to convert into: this is my code:

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 positive lookahead regex

Advertisement