3
votes
5answers
38 views

How to sort an array by a specific data segment?

I have an array of Strings like so: String[] array = { "CC/2", "DDD/3", "AAAA/4", "B/1" }; Arrays.sort(array); System.out.println(Arrays.toString(array)); When I execute this code, I get the ...
0
votes
3answers
30 views

Why am I getting this gibberish/hashcode instead of the output of my sorted array

I know the sort method (below) works on randomly generated arrays but I can't get an array I am inputting to print...instead I get something like "[D@15f068b9". Depending on how I modify the code I'll ...
1
vote
7answers
49 views

How to get maximum value from double data type value set?

I get the five double data type values from five different function.Without adding those value into array is there any efficient java code for get the maximum value from that five value set. double ...
5
votes
0answers
76 views

Why big array java is slow

I created an array of a class with big length, ~150M elements, sorted by key (describe bellow). Then I build a simple http server to feedback each request as a binary search function on the array. ...
3
votes
0answers
53 views

Getting an empty JavaScript Array in Java (Selenium test)

I need to get an empty array declared in a JavaScript script in a Java variable. The JavaScript array is declared as so on a web page: tc_vars["products"] = new Array(); (I only need the ...
1
vote
2answers
30 views

Strange array copying error

I am writing a Java3D program that draws a 3D graph. I hold the points of the graph in an array and pass it into a createMesh() and createGraph() function. Here is how I get the points of the graph: ...
1
vote
1answer
47 views

Puzzling implicit conversion during Array map()

I have a use case where I am given a Java array of wrapper classes, wrapping an int, for instance, and I want to convert them a ValueSet of the same data, but I ran into a puzzling problem with ...
-1
votes
0answers
23 views

Java sort by selection. Which is better? [migrated]

I have a doubt. Which algorithm do you think is better? And why? Hope your answers! Thanks. public static int[] selection(int[] tab) { int minor; int aux; for (int i=0; i<tab.length-1; ...
0
votes
2answers
41 views

Data Structure for keeping frequency count of pairwise data?

I have a table with hundred' of record where a field is paired with a similar field based on an id. I want to know what is a good data structure for keeping frequency counts for the number of times a ...
0
votes
5answers
47 views

Java - How to get the index of a given element in an array

I have an array of contacts like so : public class Application { private Scanner input; private Contact[] contacts; private int ArrayNum; public Application() { input = new Scanner(System.in); ...
-1
votes
2answers
54 views

The local variable “variable” may not have been initialized- Java

I got this error. Exception in thread "main" java.lang.Error: Unresolved compilation problems: rgb2 cannot be resolved to a variable its always the rgb2 array that caused the error. How to solve ...
0
votes
1answer
21 views

Trying to get data from excel then store it inside array and later print it

I am trying to read data from an excel file. When i run the below code it runs without any error but won't give any data. When i checked the code i found that the global variable rownum is not ...
0
votes
0answers
34 views

search between two arrays failing [duplicate]

Hi im sorry sorry for the long piece of code ! The aim is to find matching words from my poem in the dictionary "wb array" but it doesent find anything ( returns results that none match bud i know ...
0
votes
0answers
16 views

Reduce Complexity. Find closest pair of latitudes and longitudes

I have two arrays representing two different GPS paths. Each array contains latitudes in the even indices(starting from 0) and longitudes in the odd indices as shown below : ...
3
votes
4answers
40 views

What is the most efficient way to convert array of int to array of byte and vice versa?

I am looking for the most efficient way to convert array of int to array of byte and vice versa. I want to write a huge number of int array and String to files so I can read them efficiently. I think ...
0
votes
1answer
26 views

Can't display log anywhere in railo

I want to display log in standard browser console in Railo. This is my code : log.info("Event Handler Called"); or WriteLog (text="Event Handler Is Called", type="error", application=true, ...
2
votes
3answers
57 views

Convert 3 bytes array to number

I convert a short number to a 3 byte array using the following code: static byte[] convertTo3ByteArray(short s) { byte[] ret = new byte[3]; ret[0] = (byte) (s & 0xff); ret[1] = (byte) ...
-1
votes
2answers
62 views

Frequency of X letter words in text

I'm trying to create a program to count the frequency of 1 letter, 2 letter, etc. words in a given text file. However, it only appears to work with small files. I looked up some solutions(which I ...
1
vote
1answer
54 views

looping one array with another array in java

I have two arrays 1) String[] images = {"#1","#2", "#3", "#4", "#5" }; 2) String[] items = {"1","2", "3", "4", "5", "6", "7", "8" }; The Items may vary , but the images array is fixed. I wan the ...
0
votes
3answers
41 views

In Java how do you insert a String into a 2D array of string?

Well I'm new to Java. String[][] data=new String [][]; data[0][0]="Hello"; This does not work, can anyone explain why and how to make it work, Well in C++/Cli this works perfectly but not ...
1
vote
0answers
21 views

read csv and save in matrix String [on hold]

I would read the .csv file and the save data read in to a String matrix I have wrote this code, //visualizza attesa parti int colIndex = 0; // index della colonna degli ID del file partendo a ...
1
vote
3answers
38 views

variable may not have been initialized… how to increase scope? [duplicate]

I keep getting an error: error: variable aryResponse might not have been initialized if(answers.charAt(i) == aryResponse[i].charAt(i)) I think it's because I'm initializing the ...
0
votes
1answer
47 views

java convert Object to double array

I have a piece of code that returns an Object array. Each slice of the array then contains data that was initially a two dimensional array of doubles. I can't change this piece of code as it's part a ...
0
votes
2answers
30 views

min heap java implementation arraylist vs array

So I'm working on project for my algorithms class that I'm currently taking. I'm doing some research online and see that some people are using an ArrayList<Integer> and some people are using an ...
1
vote
3answers
44 views

After making permutations, how do I add them to an array? [Java]

I'm trying to, given some ArrayList of Integers, create all the permutations of that list. I want to store each permutation (an ArrayList itself) in a bigger ArrayList of ArrayLists. I can find the ...
2
votes
6answers
81 views

Find the location of the smallest int in an array using a method using Java

I have written the following method to find the location/index of the smallest number within the array. private static int indexOfMin( int[] a, int cnt ) { int loc = 0;//the variable that ...
4
votes
2answers
73 views

Capturing Duplicates from ArrayList

I'm having issues with removing duplicate objects from an ArrayList. Im parsing XML into what i call an IssueFeed object. This consists of a symptom, problem, solution. Most of my objects are unique ...
0
votes
2answers
62 views

Can't initialize a Two-Dimentional Array in Java

I am trying to store X axis position of mouse and Y axis position of mouse separately inside a two dimentional array and use it later but getting errors. I am new to arrays and i am trying to ...
0
votes
1answer
23 views

Android json listview with array not working

I'm using 2 activities to parse a Json, in the first activity I pass the name and when I tap on it, it shows me its contacts, and as you can see I have an array of "contatos" with 2 objects. { ...
3
votes
3answers
55 views

Java LinkedList removing zero length members

I am trying to remove members from a LinkedList whose length is zero. I am trying to make the code dynamic, where it removes all spaces from a String, yet leaving the words separate and in order. I ...
1
vote
3answers
91 views

Using ArrayList instead of an array to avoid using a normal for loop

I'm reviewing a piece of code that looks like this: public WrappedItem[] processItems(Item[] items) { List<WrappedItem> wrappedItems = new ArrayList<>(); for (Item item : ...
-2
votes
0answers
68 views

Java Arrays or Arraylist

I'm new using Java and here is my question: I'm trying to run a comparison and count program in Java where I have an excel with a 200'000 lines and 25 columns. I just need the values from cell(9) ...
0
votes
1answer
16 views

Two Dimensional Array Java TSP

I need to figure out how to get the following data into two ArrayLists or arrays... THIS THAT OTHER 1 2 3 4 5 6 7 8 9 I need the column titles to go into one array or ...
0
votes
2answers
40 views

Convert Short to 3 bytes array

I need to transfer numbers over UDP. The protocol specifies the numbers to be 3 bytes. So for example I need ID: 258 converted to a byte array: byte[] a = new byte[3]
0
votes
1answer
54 views

How to convert a java string array into an integer array of 2 dimension

i have got integer number from 1 to 64. i convert it to binary of six bits by this method below. i am concatenating it with zero because i want a string specifically of six bits(length) and so by ...
0
votes
1answer
38 views

Time Complexity for Array.copyOf()

I have a program that uses an array if integers to behave like a Stack of Integers. However, with an array, there must be a defined number of elements. When the user calls a method such as push() and ...
0
votes
1answer
22 views

How many times will merge and mergesort be run in mergesort algorithm?

These are homework questions, but I would like to understand the concepts behind them, not just get the answers. I know that the running time of MergeSort is O(nlogn). It seems that the merge method ...
1
vote
1answer
31 views

When the use sort an array, fix and write private static void sort

My Main Code is : public class Arrays { public static void main(String[] args) { //////////////// Sorting Arrays String [] castNames = new String [6]; castNames[0] = ...
-1
votes
1answer
32 views

What happens when hash tables generate huge hashcodes?

I'm a little confused about hashmaps/hashtables, because everywhere I look, I don't really get the answer im looking for. I still don't know if hashmaps use a static array or if they use dynamic ...
0
votes
0answers
37 views

JNI Accessing Object Array

I'm currently learning JNI and I'm stucked (for two days) with this problem. I have an Object that has an char array and I want to manipulate it with C and JNI. My code is: public class ImageWrapper ...
-2
votes
1answer
26 views

How to set Checkbox value into a array android

I got an ArrayList: ArrayList<CheckBox> swmsInfo = new ArrayList<CheckBox>(); and some checkboxes: checkBoxCompany = createCheckBox(R.id.checkBoxCompany); checkBoxName = ...
0
votes
2answers
36 views

Java: arrays of objects not working like non-arrayed objects

I'm writing a program using JGrasp, where tile is a class. The Following code compiles: tile ext = new tile(); ext.assignValues(0); g.setColor(ext.color); ...
-1
votes
0answers
38 views

How to read nested elements in xml with dom parser or whatever

I want to read nested elements and assign all elements and datas to two dimensional array. In the following xml example, the elements are ...
-1
votes
2answers
70 views

Prime Number Calculations Help Java

I am a novice, please excuse my lack of organization. Okay, so what I did was I made an array filled with all the prime numbers between 8 and 100. What I want to do now is make another array that ...
2
votes
2answers
84 views

Java - ArrayList not detecting duplicate value

I have written the following class for my program: public class RefGen { private static String refNo; protected static void generate(){ //Create array to store reference ...
0
votes
4answers
58 views

Add unique random numbers to an integer array

I've created an ArrayList for integers which I would like to fill with 200 numbers. Each number can be within a range between 0 and 1023. Therefore I've written this code: Random rand = new ...
1
vote
1answer
89 views

Reading a string in Character array without using any String function, not even charAt in Java

I want to read a String in a char array without using any of String class function, not even charAt(), lenght() in Java. I know one method char c=(char) System.in.read(). But in this, the user char ...
-1
votes
1answer
51 views

Android : Convert List Array to String Array show nothing

I am trying to get the data from URL and convert it into String Array, but when I try to show it on TextView its show nothing. The link and itemId that I use is already right. There's no Error ...
1
vote
2answers
30 views

sort the fitness function array

I am using genetic algorithms to evolve something and I have a double Array as shown below. fitness[0] = 15.0 fitness[1] = 12.0 fitness[2] = 13.0 fitness[3] = 17.0 fitness[4] = 8.0 fitness[5] = ...
1
vote
3answers
48 views

If an array is not full add a value to the end

So i'm working on some code that is suppose to check if all my array slots are full and if there not add my new grade to the next slot in the array and return true and if it is full return false. ...