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
Tag: arrays
How to merge multiple Arrays containing the same value in Java
I’m struggling to find the best way to merge arrays (or create new ones) by looking at their shared value. this is my “dictionary” filled with arrays of 2 words, for example it contains arrays: I need to merge them by values they share, so for example the finished “dictionary” (or completely new list) would look like this: Also, the
Given a sum of two elements in an int array, how to find their smallest indexes?
I want to return an array of 2 integers, containing the indexes of a pair of integers in the array whose sum is k. I have done this method : With previous array and sum it works & returns: For example with this: I should have: How can I, in case there are several possible pairs whose sum is equal
Converting a scanner.next() to a char[]
I want to give a function a char array from scanner.next(). I only get an error message if I try to convert it like I do it now: This is the errormessage I get: It also shows this error on the other ones where I want to pass the char[] over. Need to add more text cause they say it
Frequency of each value in an array of random integers
Need help with an assignment where I have to generate random runs between 1 to 6 for 30 balls and get : 1.Total runs scored 2.Number of 0s, 1s, 2s, 3s, 4s and 6s 3.Strike Rate While I have got ‘Total runs’ and ‘Strike rate’, I am unable to get the frequency of 0s,1s… I have tried using counter and
How would I move a blank space in a 2d array?
I’m working on a Slider puzzle game and I’m not sure how I would go about moving a “blank” around the array. The puzzle would something like this but randomized. Each method has a prerequisite indicating if it can move a certain direction or not. Answer Here is an example of how you could implement right(), the rest of the
Enter a number within a certain range, and then get the system to prompt me to input names for that number that has been entered?
I am trying to input a number between 1-10, if a number is entered which out of this range 3 consecutive times, the system should terminate. If the number is within the range, it should then prompt the user to enter names, which should match the number that was initially added. (So if 3 was inputted initially, the system to
How to obtain the last number different to zero in an array in Java
I have for example this array: And I want to find the last number of the array different to 0. In this case, my output should be: 9.0 My code is: But it doesn’t work. I need to highlight that the size of the array1 is always the same. But the non-zero numbers can change, in any case, all the
How do I print a returning Array of objects ? I could only print the first 1
I created a function that gets an array of objects and the type(String) of the abject and returning an array of objects with a specific type and after that, I tried to print it but it only print the first 1, not sure what went wrong. The objects are Tables: //I made a full contractor: //and a setter getter for
In an array of arraylists, get the largest arraylist
I have an array with multiple arraylists of different sizes. I want to find the index of the largest arraylist in the array. I tried this: disc being the name of the array of arraylists. ArrayList I believe doesn’t implement the Comparable interface so I can’t do it like this. Is there a way to make a custom comparable for