All Questions
21 questions
0
votes
1
answer
25
views
How can I add every element with the second and 3rd element after it in a grid (2D array)?
I have a 2D array and I'm trying to add element x to the two next elements in the grid horizontally while not going out of bounds.
For instance,
if this is my grid,
[1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, ...
1
vote
3
answers
474
views
Filtering rows of a 2d array by a certain value
I am a beginner in Java. For my task I've been given such table. The table represents 6 runners who participated in 7 races. The value in each cell is the place they got in the particular race:
The ...
0
votes
3
answers
214
views
Iterating through a 2d String array to show all combinations of given array
I am wanting to try and implement a way of iterating through all possible variations of values inside a 2d array.
Similar to what can be done with a set of 1d arrays such as:
String[] pos = {"1&...
0
votes
1
answer
143
views
In Java, how would I make for loops that iterate through a 2d array, and when a certain value is found, print a line and then exit the loop?
I am working on an assignment that is making a program that adds and subtracts passengers that are on a plane, displayed via a 2d array. I am trying to write code that will check if the seat a ...
2
votes
1
answer
610
views
How to shuffle a deck made with two dimensional array
I am having an issue shuffling two decks. I created two decks using a two dimensional array. Keep in mind that those were the requirements. I am also required to shuffle them using a method called ...
0
votes
1
answer
292
views
Obtaining a list of arrays by diagonally traversing a 2D array with left-leaning diagonal sections?
I know I can just use for (int i = 0; i < myArray.length; i++) or a enhanced for-loop to iterate completely through a loop.
However, I am trying to create new char[] arrays by completely iterating ...
0
votes
1
answer
289
views
How to iterate through a rectangular 2D array and create char[] arrays with backwards (left-leaning) diagonal sections?
I want to use a rectnagular array to create another 2D array full of left-leaning diagonal sections from it.
I have read the top answer in this question, and I've tried to make it work for me, but it ...
1
vote
3
answers
3k
views
How to iterate through an arraylist of an arraylist of strings?
I'm creating a program that allows users to interact with a file thats input. One of the options is to display the file. Below, I store the file into an arraylist first by creating arraylists ...
-3
votes
1
answer
40
views
Java 2D Array return not correct, why? [duplicate]
Why I get -1 returned? For sure the name is in stadiumSeats[i][j].
`public int searchForGuest(final String name){
for(int i=0; i<stadiumSeats.length; i++){
for(int j=0; j<...
1
vote
2
answers
102
views
How to count up X times after an element is found in a 2d Array in java
I am fairly new to java, and I am just wondering how I would find an element, X amount of spaces, from the desired element in a 2D array. Here's an example to explain if what i'm asking doesn't make ...
1
vote
2
answers
165
views
Multidimensional arrays: Java. How does this code work?
I've been following a tutorial about creating a basic tile-based tower defense game in Java and have encountered a piece of code I cannot wrap my brain around and would like some help. (My main ...
0
votes
0
answers
444
views
Checking if a board configuration is valid (similar to Sudoku )
I have a puzzle that involves a board that will look like this:
The outside numbers represent how many visible "buildings" can be seen from facing in that direction. SO if there is a 1 on the north ...
0
votes
3
answers
896
views
Checking if multidimensional ArrayList has a value multiple times
I have a multidimensional ArrayList of variable size (in the example I will assume it contains 3 ArrayLists).
These ArrayLists contain Team objects that look like this: Remco & Joris.
I am only ...
0
votes
1
answer
1k
views
How can I check to see if elements of a 2D array are null in java?
I have a 2d arrays centroids which each of its elements is an array itself. How can I check to see if say centroids[1][1] list contains any element?
I thought this code would work but it is not.
...
-2
votes
1
answer
90
views
How to avoid ConcurrentModificationException when removing from collection [duplicate]
I'm having problem with my delete command of my array list while I'm iterating it. How can I resolve the ConcurrentModificationException?
protected void deleteModeOfPayment(List<List<String>...