I am stuck in the middle of ‘generic-type-qualifier-land’ and can’t find the right combination of type qualifiers. I have a class that represents a flexible array that can have a number of different types in it. The class holds an ArrayList<Object> as the container for the elements. There are type specific accessors, like getString(i) and getInt(i) etc. I would like
Tag: arrays
How create a JSONArray in java
I have 2 java functions: listeFilesHdfs return a list of files that stored in HDFS, for example: If you remark, the files that stored in HDFS there content is a JSON format, for example: I created the below function to call both function above (one return list of files and the second open a path): How can I modify my
Compare elements of two arrays of Object
I am trying to build a generic merge method, part of a mergeSort algorithm but I am stuck on how to deal with the comparison. This is my code so far: public static Object[] merge(Object[] left, Object[…
Game Of Life game: Check 2D array 8 closest surroundings; ArrayIndexOutOfBoundsException issue
I have encountered this problem and i couldn’t find the solution. There is a 2D array with only zeros and ones in it (the size of the array doesnt really matter, i worked with 10×10). Zero means dead and 1 is alive. I double for looped this to check the elements sorroundings and when it sorrounded with other “cells” the
Java multidimensional arrays – How to refer to the length of different dimensions
We are learning about 2D arrays in my AP computer science A class and I have a question that I’m struggling to find the clear answer to. For some context when I’m talking about my question, ragged arrays are out of the picture and when I refer to rows I am talking about arrays going across and when I refer
Is there a way to copy int[] to another int[] without repeated ints?
We can’t use ArrayList or something like that, because the teacher told us to not use them, so I got stuck at this point. The signature of the function is: public static int[] deleteNth(int[] elements,…
Adding a newly created object into an array in swift
I decided to start a project in java to get a rough outline of how the program was to function before I started to program it in swift(a language I am completely unfamiliar with) whilst trying to convert the code I’ve ran into an issue and cannot even understand how I’ve gone wrong. This is context for the code In
How do I efficiently count elements less than a certain value in a sorted array?
Say for example I have a sorted array: And a key value 80 How do I efficiently count all values from 80 below without iterating through the whole array with an if condition? I was thinking Binary Search but then again i’m not searching for any key, I just need the fastest way return the count of values less than
How can i make my turn my text file to 40×40 matrix [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question In my code i need to read my text file and create a 40×40 matrix however my array only reads
Sort 2D array by average value of each line
I have complex task to differently sort two dimensional array manually. So far I get done those tasks: User needs to input row size from 10 – 20, Generate 2D array where row size is user input and column size is randomly generated from 10-50, Each array is filled with randomly generated numbers from 100 – 999, Output each array