By using Java 11, I am trying to find the average value inside the ArrayList. The algorithm i want to develop is ((value inside list/maximum value)*100)/length of list). I got number format runtime error while I run the program. java.lang.NumberFormatException is the error i got. enter image description here Answer I find two issues with the code above: The parsing
Tag: list
How to sort a list by multiple fields in different orders (asc/desc) in Java?
I have an ArrayList in Java and each element in the list is an object with 3 fields (a, b and c). I should order by a in ascending order; if 2 elements have the same value for a, they should be ordered by b in descending order; finally, if 2 elements have the same value even for b, they
How to i iterate and compare two lists
Here I’m trying to compare two lists position wise that is the first element from list1 has to be compared with only the first element of list2 and if they are equal it should be replaced with the empty string in the output list and if they are different the element in the second list has to be updated in
How to search an item in a queue type list and then change it in Java?
I’m trying to find an item of a node in my queue type list, in which it goes through it until it finds that and then replace it, for example: I have a “person” object with its respective get and set I have a generic “node” with its respective get and set And finally I have a manual generic “queue”
Converting to List result in Java
I have the following method: In this method, I pass a single menuUuid and then get combination of a single MenuPropertiesDTO and List<GroupExpDTO>. I want to pass a List<menuUuid> instead of a single menuUuid and then get the result according to the uuids in this list. However, I am confused if there is a proper way for this in Java.
How to get certain values from ArrayList and put them in a map
I have a program where there are 52 cards and int number of players (for example lets start from 4), the task is asking me to put elements like this in a map of Map<String, List>: I have written the logic like this: Any suggestions how to put those List in the map according to the task? Answer Since cannot
How to randomize ArrayList without using Collections.swap()?
I was asked to create a method that randomly rearranges my list which contains arrays. The list contains multiple persons and their names and surnames. My question is how do I move a person (array containing two elements name and surname inside the list) to a different index without using the method swap()? Because our list does not support that
Append list according to their size in Java
I am trying to append two list according to their size. With list with bigger size in front. I have few lists like this. List<Pair<Double, String>> masterList = new ArrayList<>(); and this is the working Java code that I tried first – with a simple if else loop: I am fairly new to the Java, so I was studying about
Method to display particular types of pizza from a list in Java
I have a simple pizza program in Java, made using the Factory Pattern. Basically, when a factory is given as a parameter, it creates a particular pizza, which is then added to the list of pizzas of the PizzaShop. I would like to create a method that displays how many particular pizzas I have. For instance, when the method is
Merge an List of Object and an Object to a new array in Java [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 10 months ago. Improve this question I have List<BigInteger> sample1 = Lists.newArrayList(BIGINTEGER1, BIGINTEGER2,BIGINTEGER3); I have to create new List sample2 with one more value BIGINTEGER4 along with sample1 list: How can