Skip to content
Advertisement

Tag: arraylist

Cant add to arraylist inside actionevent Buttonclicked

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

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

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

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

Advertisement