Skip to content
Advertisement

Tag: arrays

Sort 2d String array by integer in first column

I have a 2d array in Java 8: String data[][] = new String[i][2]; And it looks like this: Player1 8 Player5 3 Player3 9 Player4 5 … and I want to sort it to have the highest score at the top: Player3 9 Player1 8 Player4 5 Player5 3 How can I sort this or is there a better way

How to sort array based on multiples of 3 using Java

I have an array like this one- {1, 2, 3, 4, 5, 6} I want to sort it in the order of multiples of 3 with remainders 0, 1 and 2. (the first group is multiples of 3, the second one is multiples of 3 with remainder 1 and the last one is multiples of 3 with remainder 2) and

Add strings to an array of strings inside for loop using java

I have a for loop and I want to add strings to a string array inside that loop. How can I achieve that? The output should look like this- Answer You can create the result array with a size that matches the registration array length, since you know you want to create one result for each registration entry. You then

Java: Generate array from 1 to n with step size

I have trouble with a quite easy task. I want to have an array from 0 to a value n with step size t, always ending with n. Example 1: n=10, t=3, array={0, 3, 6, 9, 10} Example 2: n=20, t=5, array={0, 5, 10, 15, 20} Example 3: n=1, t=1, array={0, 1} I have code which I have been using

I need help Returning a string representation of my circular queue

I am trying to returns a string representation of my circular queue heres what I have so far. (Im not allowed to use/import other libraries in my code) My public String toString( ) doesn’t return the right numbers on my test driver. I think it has something to do with it not circling the array. And my driver: Help would

Advertisement