I have an android application that basically scan a barcode. I have a lists of items and I would like to change a color of my list once the item has been scanned. Please find the image below for reference. I would like to change a background color of item to red only if the item remaining is zero. There
Tag: arraylist
Data in the List gets modified after changing the object in another List
After adding the object into my list I am changing the data in the list it is getting modified I have the code like If I am doing like this, the data object in the newList also is getting changed. I have a requirement that it should be changed in the oldList but it should not change the data in
How to return arraylist vertically
I am trying to return an array list vertically but I’m having some issues trying to implement it. Below is my code, and the return results; Output is what I’m trying to get to be vertically } My current output is [2, 4, -1] I’d like it to be Any help would be appreciated. Thank you in advance Answer Hi
how to compare the two names in array list
I am trying to compare the two names in the baby array list if it is true it will return “Two babies in the array are the same” if false will return “No same baby in the array”. But I just can’t get it to work for the findTwoSameBabies method, it is supposed to compare all the names in the
printing all subsequences of an array using recursion in JAVA
The following code for above requirement. However I am not getting proper output. There is problem with input list that I am passing in recursion Answer The problem is not, like you said in your comment, that the list ip keeps elements of the previous function call. The problem is that you don’t create a new arraylist as ip parameter
How to create a functioning program that acts like a calendar with methods that block multiple ranges of dates and return the available dates?
The following is what I was able to complete: For the setBlockDates() method: write a method to block multiple ranges of dates from the dateRange ArrayList. Here I should be able to enter multiple ranges to block, such as ([1,4], [8,11], [17,24]) For the getAvailableDates() method: write a method to return the available dates in the dateRange ArrayList created below.
How to use generics for type safety while using `removeRange` method of ArrayList
Since the method – removeRange(int startIndex, int ) is protected, we need to use it in a class extending ArrayList. Below is my code – Output – Now to use type safety I need to write – MyClass<String> extends ArrayList<String> but doing so gives error in main method of String[] – MyClass.This cannot be referenced from a static context So
Select Random element from ArrayList print then remove It
Hi so I have this array list of questions and I want to choose it randomly then delete it one by one until there’s no more so that It wont load the same question twice but there is some problem for example I have 3 questions in the question arraylist sometime it only loads 1 or two even the same
Sorting an arraylist with lambda function isn’t working
I’m trying to use .sort() method with an arraylist. My method public void sortSurname() should sort alphabetically all the objects by their surname, these objects are contained in an arraylist ArrayList<Contact> contacts. Could someone please find the issue with this code? Here is what I’ve written so far: Contact class Rubrica class Main Thank you for the help. Answer The
How to save Each index of Array List in text file as new line in java?
I am trying to save each index of list as new line in text file in format below in java and read same as two separate Array List for later . I have done the saving part now i want to read it back into two separate lists Save Formate Class SaveLists Class Main : Answer As both the save