0
votes
1answer
16 views

Displaying 2D array results excluding nulls in Java

I'm creating an array that will sort arrayString[10][2] and then display the results to the user using JOptionPane. The length of the 2D array is irrelevant, just note that it will not be completely ...
0
votes
1answer
32 views

Java Swing do-while Null Pointer [persisting] Confusion

I am continuing to receive this NPE despite the following evidence I have that my array does in fact exist: Using this code I reference a 2D array of strings, I select an element at random, the first ...
0
votes
1answer
22 views

Java serialise array

Alright I have writen a fairly complex file system in which I need to store an array of classes. In order to do this I have written the following function. However when I call this function the file ...
0
votes
0answers
22 views

Distribute values from a map to an array in a balanced way

I am trying to get a balancing algorithm but struggling to understand how to acheieve this. I have a HashMap as below: Map criteria = new HashMap(); criteria.put("0",5); criteria.put("1",8); ...
0
votes
1answer
20 views

Substitution code working one way but not in reverse

I'm trying to make a simple "translation" project as i'm still learning java. But something went wrong and I've spent many hours and still no idea how to fix it. Here is the code: public static void ...
0
votes
0answers
9 views

TransformException when serializing 2D array of my own class (Simple 2.7.1)

I'm having trouble serializing 2D arrays of classes I've made (e.g. Foo) with Simple 2.7.1 @Root public class Foo { @Element public int value; @Element public String name; public Foo(){} public ...
4
votes
4answers
70 views

Comparing 6 int arrays in java

I'm trying to solve a puzzle by programing it. I have int 6 arrays and each one has 6 numbers. I have to choose one number from each one to come up with a sum of 419. I'm almost a beginner in Java. I ...
0
votes
2answers
35 views

Println statements not printing

I have three files in one project and I can't seem to make the println statements in my main class print! Help? First file: package chapter2; public class UseStringLog { public static void ...
0
votes
3answers
59 views

Null Pointer that makes no sense to me?

Im currently working on a program and any time i call Products[1] there is no null pointer error however, when i call Products[0] or Products[2] i get a null pointer error. However i am still getting ...
-1
votes
0answers
11 views

How to sent a string array from java to matlab

I want to create a HeatMap in matlab but want to pass all the data from a java program to matlab. I am able to pass primitive data types like a double array from java class to matlab but when I pass a ...
0
votes
3answers
72 views

How to find repetitive patterns in char array?

I have an array of characters: a b c x y d e f x y a b c t r e a b c How can I find repetitive patterns of sizes 2 onwards? The array needs to be traversed from the end. In the example I need to ...
0
votes
1answer
53 views

Basic array with switch statements

I have here my code here where I am doing some simple Array stuff. Originally this is the output of my work: Output: Enter an item: _ // I don't know why I should have this. Main Menu ...
0
votes
1answer
29 views

2D object giving a nullpointerexception?

I'm having a bit of a problem when running the code below. This code is used when a button on a gui screen is pressed. Basically the function of this button is to read text entered into 2 text fields, ...
1
vote
1answer
14 views

Interface & StringLog Confusion

I am reading the book Object Oriented Data Structures using Java and I'm in chapter 2. I decided to try out one of the exercises they had in there but the code does not seem to work for me even though ...
0
votes
2answers
42 views

How to modify the content of an array according to its content ordering efficiently?

I have a question regarding array. For example, if I know the size of the array will be 5, and my programme read in [9993, 1000, 9992, 3, 872] into the array, how can I edit the content of the ...
0
votes
0answers
14 views

smali file: add one value to array

I need to add one value to a hard coded string array in my android app. Unforunately I have lost my hole code, so I decomplied the apk to smali. Can someone show me how I can add an entry between "1D" ...
0
votes
2answers
38 views

NullPointer when passing String Array between two activities in Android

I am trying to send an array of Strings which basically include a path of a file on the device. First the user Selects Picture 1 and then Select Picture 2. Once the user completes that the array is ...
0
votes
2answers
33 views

Unexpected result while taking input from user through constructor

This is my code. For any kind of input i get the output 0 0 0 0 0 0 0 0 0 0 I can't understand why? import java.util.*; class TestArray{ int[] a=new int[10]; TestArray(){ for(int ...
1
vote
2answers
46 views

How to store a csv file in a multidimensional String Array

I am new to java and csv files. I would like to store a csv file in a multidimensional string array but I don't know the number of lines in the file and its fields. So how can I get the number of ...
0
votes
2answers
58 views

JSONArray without array name (earthquake example)

Regarding another thread here i try too, to get a json array form a json. I have the following files : earthquake.json [{ "eqid": "merge", "magnitude": 8.8, "lng": 142.369, ...
2
votes
2answers
49 views

Array Search of Generics java

I am trying to search an array of any data type (Int, Strings, Chars, etc...) to see if there exist an element that matches the one you input. You should return the index of the matching element. ...
1
vote
1answer
40 views

getting a proper value from an array at specified index

I'm creating a game in Slick2D. First, let me show you the GUI state where I'm stuck. http://imageshack.us/photo/my-images/593/4v3v.jpg/ So, I have a problem in a class SettingsUI, with ...
0
votes
1answer
35 views

What information from a class do I pass to get desired results

I am working on taking a file and putting it into an arraylist. Then using the split method from the String class to make an arraylist with the formatted tokens. In my tester class it lets me put in ...
2
votes
2answers
30 views

why are single dimensional array types not listed in the constant pool table of a .class file?

If the code calls new int[0][0], the entry [[I will be placed in the constant pool table. A similar entry would be placed for a higher dimensional array. However, if the code calls new int[0], no ...
0
votes
1answer
55 views

adding multiple objects to an array

I want to add all of the user input I just received and put it all into one array position. Scanner sc = new Scanner(System.in); int cit = 0; //cit = Integer.parseInt(sc.nextLine()); /*if ...
1
vote
4answers
46 views

How to write a conditional/if statement to be true if an object is in the array

What i want to do in this conditional is make sure the object in the array (neighbors of the middle cell) is physically inside the array, so i thought i would just make the third variable in the ...
-3
votes
1answer
47 views

Make a smaller array from a larger one based on input size java

If there is a better way to do this i will be happy to listen. I want to create an array with the size of the user input. At the moment the only way i can all the user to enter data into the array. ...
0
votes
3answers
43 views

NullPointerException in PrintWriter[] array - Java

I have a problem which i am trying to figure out for days now. Simple Code Overview(PseudoCode): 1 - When a user connects create a PrintWriter for him. 2 - Store the PrintWriter object into a ...
4
votes
2answers
114 views

Sorting multiple strings into an element

Below is a small extract of a very large file. I'm looking for a way to get each name and value (on the Name(x) and Value(x) lines) into an element of a Array or List type with an "=" between the ...
3
votes
3answers
53 views

Java: Assign Object array with Integer elements to Integer array

I searched the internet but didn't found any appropriate solution. In my application I've got an array of integers. I need to access (assign to) the array via reflection. The application creates an ...
10
votes
1answer
49 views

When to use Array, Buffer or direct Buffer

Question While writing a Matrix class for use with OpenGL libraries, I came across the question of whether to use Java arrays or a Buffer strategy to store the data (JOGL offers direct-buffer copy ...
1
vote
1answer
57 views

Adding a 1d array in 2d array in java

I am writing a code where i have to add a 1d array in 2d array. For example: I have a userlist array which will add data array in it Double[][] userList = new Double[4][appName.size()]; Double[] ...
-2
votes
0answers
24 views

Read file line by line and set into an array?

I am attempting to make a plugin for Minecraft that does not allow users to advertise. I do have it working, actually, at the moment but I'd like to make it more efficient. The code as of now: ...
-2
votes
1answer
34 views

Adding Name and phone number to conctact list on JAVA

Hey guys! After adding contact to .txt file it gets overwirttten, i need new contact be parsed and stored in new array.. any suggestions? package kontakter; public class KontaktGUI extends JFrame ...
2
votes
4answers
47 views

How do i Swap Data of an Arrays?

public class Swap_Numbers { public static void main(String[] args) { int numTens[] = {1, 2, 3, 4, 5}; // First array of numbers int numHundred[] = {100, 200, ...
1
vote
4answers
61 views

How to convert byte array in String format to byte array?

I have created a byte array of a file. FileInputStream fileInputStream=null; File file = new File("/home/user/Desktop/myfile.pdf"); byte[] bFile = new byte[(int) file.length()]; try { ...
1
vote
1answer
111 views

algorithm to convert large numbers to small in java [on hold]

I have set of numbers from 1 to 100 000 000 000. But total amount not more than 50 000. Seems that is possible create array of objects with 50 000 elements. So I could take element from array by index ...
0
votes
7answers
48 views

What kind of data type should I use if I have to implement Binary Search on a large amount of data?

Edit: Okay my question has been answered. Thank you. Initially I had doubts about using an array of 1 million cause I read it caused some problems in C, so thanks for your responses everyone! Okay hi ...
0
votes
4answers
58 views

Delete character in certain position in array

What I am looking to do is delete a character at a position in an array. The array is called word. removecharacter is an int word is a an array that was formed from a string There is a test program ...
0
votes
3answers
69 views

Java Calculating average from users input

I have a problem with my code.Please help me to solve it. Program should quit and return average when q is entered. If you enter 5 numbers it is working fine. The array size should be 20. Here is the ...
1
vote
2answers
40 views

finding the sum of a 2D array in java

I'm new to java and I have to find the sum of a 2D array but my code simply won't compile. I keep getting the errors : 3 errors found: File: C:\Users\Brett\Documents\DrJava\Matrix.java [line: 9] ...
0
votes
3answers
62 views

Do Java generics allow for memory savings in arrays of primitives such as short?

I've done a bit of Googling, but I've been unable to find a decisive answer to this question. For clarification, consider a class like this: public class MyContainer<T> { private T[] ...
1
vote
2answers
58 views

Why do i recieve “[Ljava.lang.Integer;@72608760” when i attempt to print out an Integer array [duplicate]

Here is the code. public class PokerGame { public static void main(String args[]) { Scanner kb=new Scanner(System.in); Scanner nkb=new Scanner(System.in); Random r=new ...
-1
votes
7answers
73 views

Array issue out of bounds [on hold]

I have tried so many variations of this code and I can't seem to get it correct. I get an array out of bounds issue for the second if statement if I try something only with two parts. However, it ...
1
vote
0answers
59 views

Is there a reason for Java not having decomposable Arrays? [on hold]

After looking into a bit of C, the only thing I liked in it was the easy decomposition of Arrays using pointers and varying lengths. In C, assuming you have a function void sort(int *array, int ...
0
votes
6answers
68 views

Computing sum of elements in array

I have a class Mold with the following constructor public Mold(int[][] mold){ this.mold = mold; } I also have a method sum() which looks like this: public int sum(){ int sum = 0; ...
1
vote
3answers
49 views

Don't understand error message

public class ArrayPrac { public static void main(String[] args) { int[] arrayOne = {2, 3, 4, 5, 6}; System.out.println(findMin(arrayOne)); } public static void ...
0
votes
1answer
47 views

how to add array values inputted in one edittext in java eclipse?

I am making a program that add the array values. My input is like this way... for example i will input: 10-20,20-30,30-40 It will loop and the computation goes this way.. (10+20)+(20+30)+(30+40) I ...
0
votes
4answers
64 views

String array to string with format

I have setup 3 text views each set to maximum of 9 chars. The user can edit these text views and save them to file. I first convert the string array to string. ...
0
votes
3answers
63 views

java implementation of Depth First Search

the following code has no errors,but the output i am getting is not correct import java.io.*; class dfs { static void dfs(int a[][], int m[], int i, int n) { int j; System.out.println("\t" + (i+1)); ...

15 30 50 per page