Skip to content
Advertisement

Tag: arrays

Do arrays in Java store data or pointers

I was reading about data locality and want to use it to improve my game engine that I’m writing. Let’s say that I have created five objects at different times that are now all in different places in the memory not next to each other. If I add them all to an array, will that array only hold pointers to

Java – Creating 2D Array with same size as another 2D Array

I have the following 2D Array: And I want to create another 2D Array with the same size of matrixA, my question is how do I do it with, the same way of an ordinary array, i.e, int[] arrayA = {10, 12, 33, 23}, int[] arrayB = new int[arrayA.length] Can I do it like this, only alocating one array with

how to traverse a Boolean recursion array

The exercise: Build a recursion(with no loops) that every cell that you go inside is the number of steps that you can go, it could be right/left until you get to the last cell. if you can’t get to the last cell return false, else return true. you must start from index 0. My problem: I build the program, it’s

Java Arrays/Loops

Hi i saw this question online and i was trying to solve it but i just could not understand how the answered was determined. The answer is 1 which i have no idea how or why is it 1. Wonder if anyone is kind enough to explain why is the answer 1. Answer The code block inside the if swaps

List of array in Android

I am creating OMR scanner in java. I have List of which contains contours from image. i want to create array of List. how can i accomplish it? this is what i have right now What i want to do is so that i can store array of countours() for each question. Like [1] contour1,contour2,contour3,contour4,contour5 [2] contour1,contour2,contour3,contour4,contour5 [3] contour1,contour2,contour3,contour4,contour5 ………………………….

Merge two arrays in alternate fashion

I am trying to merge to arrays of int type with the same size. Here’s my code When I try printing the numbers in first for loop, it gives me 1,4,2,5,3,6 which the correct output. But, When I try printing it outside the first for loop it gives me output 1,2,3,6,0,0. Can someone help me? TIA Answer In your for

Need explanation for algorithm searching minimal large sum

I’m solving Codility questions as practice and couldn’t answer one of the questions. I found the answer on the Internet but I don’t get how this algorithm works. Could someone walk me through it step-by-step? Here is the question: And here is the solution I found with my comments about parts which I don’t understand: Answer So what the code

Advertisement