Im kind of new to programming in java but here im trying to figure out how to add the value of a button clicked in ActionEvent. I even changed the actionlistener to MouseListener etc but still not working. It only displays the current button clicked but i would like to add every button clicked into an arraylist. Problem: I cant
Tag: arraylist
How create a list of an object from two different types of lists
I have two objects that have two fields in common, code field and position field. I use two distinct lists, one of Object1 and another of Object2. Object2 was filtered before and had missing elements compared to Object1. I need to stream() on Object1 to compare code value and position value of objects that are still in the list of
Java: reading objects from file into different derived classes
I have class Employee, and two derived classes Hourly and Salary. Instantiations of those derived classes are placed in the same Array List called employeeList. When I read these objects from file using ois.readObject() how can I ensure the data ends up in the appropriate derived class? Thank you! Answer Note: I am not familiar with ObjectInputStream, so I am
Unchecked assignment: ‘java.util.List’ to ‘java.util.Collection’
I am having an adapter where i have two lists one list is for InvestorsList where it comes with the list of investors and the other list is called investorListFull which is used to filter results when searching. Below is how i have declared the lists Below is how the lists are assigned in my recyclerview adapter constructor Below is
create a sub list of elements based on user input
I wrote the code below, where from an initialized list of countries the method will return all the countries who have a longitude of >= 5, the code works but now I want the method to return the name of countries that are close to String D within a 5 degrees range of longitude. I tried implementing the scanner as
Java – changing an arraylist from another class
So, I’ve made a public arraylist that I need to change from another class. shielded is an arraylist, that stores the UUID as a string of every player that has toggled the shield on. This code does not affect the array in class one, but still lets me toggle it just in that class. After accessing it in Class 3,
Adding in hashmap by while loop but not working
I have the following CSV file and I would like to create a hashmap which the unique key should be the first value of each row and value should be an arraylist containing the information of each line under the first value of this row. Example CSV as below: So ideally, I would like the final ArrayList to be something
How to remove an element and the element after that in an ArrayList if the value of the element is less than a specific integer?
I have this program where I need to remove the value from an ArrayList and the value after that if the value is less than 10. Here is an example: Original ArrayList: [20, 40, 15, 4, 25, 50, 45] Modified ArrayList: (if the value is less than 10) [20, 40, 15, 50, 45] – (Removed 4 and 25 because 4
Returning a subset that has a duplicate
My question is how to detect the duplicate on one subset of array that does not exist in the other substring? For example Input: arr1 = 1,2,3 arr2 = 1,1 Output: Arr2 is not a subset of Arr1 So far everything else works fine and how I want it to but this duplicate one keeps returning that it is a
How do I return to the beginning of a while loop?
I’ve only been taking coding classes for a month, so I’m really sorry if I’m using some wrong/wacky constructions. I’m trying to make an addition game using two random numbers; r1 determines the number of terms in the addition problem, while r2 assigns a value to each of them. The scanner checks the user’s input and based on that the