Tagged Questions
-4
votes
4answers
68 views
How to add elements to a fixed size array in Java after the last non-null element?
So I have a String array with length 10. I add one or two values and the rest is still null. I want to be able to go back and add more values starting from the first non-null element. How do i get the ...
2
votes
3answers
63 views
Wrapper-class for Java array of generic instatiation of its elements
I'm currently writing a Game in Java.
In this game I am using arrays as data-structure for stuff like bullets.
Now I failed writing a wrapper-class around arrays using a generic type.
I constructed ...
75
votes
7answers
177k views
0
votes
2answers
59 views
Can I customize the index of a matrix in Java?
I want to implement in Java a matrix with custom index like this example:
country1 city1 name1 region1 population1
country2 23 5 55 ...
city2 5 9 .
name2 ...
2
votes
1answer
703 views
pass an array to a paint component class?
I have another beginner's question that hopefully someone can help with.
I'm trying to pass an array from one class to another in order to use it to produce a bar graph. I know I can pass an array as ...
26
votes
6answers
46k views
JSON Array iteration in Android/Java
I am building an android app that needs to download and synchronise with an online database, I am sending my query from the app to a php page which returns the relevant rows from a database in JSON ...
2
votes
2answers
70 views
Why does sort take an Object array?
I just stumbled upon the following overloads of sort in java.util.Arrays:
public static void sort(Object[] a)
public static <T> void sort(T[] a, Comparator<? super T> c)
Why is the ...
-4
votes
0answers
43 views
Score Four Java need help getting certain values and checking if co-ordinates are valid [closed]
This class handles the game and its execution and i've initialized all the variables but i'm quite unsure on how to begin the next method , there are two players playing the game for the second ...
0
votes
1answer
28 views
How to read local text file and put data in an array to prepare playlist in android
As you can see that in this player I want make an array which can fetch list of video paths from a locally stored text file in the internal memory of the device.As u can see in the below code that I'm ...
0
votes
1answer
49 views
Adding objects to arraylist and sorting it
I wrote a program in which I add objects to an arraylist and then sort it by ID. Here's my program:
package TestPackage;
import java.io.File;
import java.io.FileNotFoundException;
import ...
0
votes
2answers
26 views
Binary Heap class constructor
Can anyone explain the BinaryHeap constructor? (see below the java codes)
I don't understand the following lines:
array = (AnyType[]) new Comparable[ ( currentSize + 2 ) * 11 / 10 ];
for( AnyType ...
0
votes
3answers
115 views
An Arraylist of Arrays or os there a better way?
So thanks to the wonderful people here i've managed to get something semi workable, still have a couple bugs but maybe you guys can help me figure it out. So far none of the solution provided were a ...
0
votes
1answer
36 views
Calling a specific member of an object array from another class-method
I am now working on the AI section of my project. I am calling a method from my AI class which is intended to calculate where the Gladiator objects I have drawn need to actually end up. I passed to ...
2
votes
2answers
41 views
Passing on a filled array onto a public variable so it can be used in other classes
So I've been working on a GUI that has the basic layout completed. I have the logic all mapped out but the issue I am having is figuring out how to set a filled array to a public variable with all of ...
0
votes
4answers
78 views
Comparing array entries
So I'm extremely rusty with my java programming. I'm trying to create a hypothetical company lottery where each employee can only enter once. Then a name will be randomly generated announcing the ...