Tagged Questions
0
votes
4answers
83 views
JAVA - How to create an array of objects?
I need to read a CSV file into an array of Objects.
I didn't realise that it had to go into one, and just made an ArrayList instead. I now need to fix that, and have no idea what I'm doing.
This is ...
6
votes
1answer
76 views
Should I use `new` with an inline-initialized array?
As far as I can tell, this code:
int[] numbers = new int[] { 1, 2 };
is the same as this code:
int[] numbers = { 1, 2 };
In fact, the compiled .class disassembles to the same code:
1: newarray ...
0
votes
4answers
48 views
Importing CSV file into 2d array - don't know array size
I have to read a text file into a 2d Array.
The only problem I am having, is the width of the array varies, with a maximum size of 9 columns.
I don't know how many rows there will be.
Some lines ...
0
votes
2answers
48 views
performance penalty for storing and updating implicit information (arrays, Java)
I am writing some performance critical Java Code and I am really no Java expert, to say this in advance.
I work with a model in which nearly all information can be calculated from the positions of ...
-6
votes
1answer
38 views
An arrayPattern. Creating an array with a pattern [closed]
Please help. I have no idea what this pattern is and how to code it. I know that you take the length squared and that is the amount of ints you are supposed to return but other than that I am ...
-6
votes
3answers
62 views
I can not make the array global
I need to write the arrays in a single line and carry it over through several different classes. here is my code so far. How would I go about making the arrays global? I am very confused.
This ...
0
votes
3answers
86 views
Printing string array also prints null
When I am printing contents of a string array the output is printing 'null' as well. I am not sure what's wrong with this. Here is the output, what I expect is the output without 'null'
...
0
votes
2answers
90 views
Java - Return an array that contains a multidimensional Array
I've been trying to solve this for the past couple of hours with no luck, Here I'm supposed to pass in a multidimensional Array from the main method, to another method that's:
public static int[] ...
1
vote
1answer
47 views
java arrays of parametric types
This is not a question how to do things. It is a question of why is it the way it is.
Arrays in Java know their component type at run time, and because of type erasure we cannot have array objects of ...
1
vote
2answers
89 views
Java: Breadth-First-Traversal Order Over an Array
I wish to iterate over a sorted array in the order that a breadth first traversal would give if I put the array into a binary tree and performed a BFT on that (which is how I currently achieve this). ...
0
votes
1answer
40 views
Sort Array of Objects by Objects' Property [duplicate]
I know there are a lot of questions like this, and I have been reading a lot but I really can't figure it out. I have a user defined object, Team, which has the properties team name (String), batAvg ...
1
vote
0answers
90 views
Object in Object Array doesn't want to store my data
fairly new to this language. Long time lurker, first time question asker.
In my program, I load a bunch of strings from a text file and then pass all of that information inside of a String array to a ...
0
votes
1answer
42 views
Swing - Save textField in Array
I have a problem with java Window Builder application.
I need to make this application to save the name (textField) into an array variable from another class.
So, when you press the New Name button ...
5
votes
3answers
57 views
String array without initial size gives null pointer exception
I was just checking some OCJP questions and came across this difference during String array initialization and exceptions.
Case 1
try {
String[][] b = new String[10][10];//1
...
1
vote
2answers
54 views
Searching for null slot in array
I am trying to search for the first null slot in the array. Can you parseInt() quotes to do this, or would I use "stobar[b] == null"?
int[] stobar = new int[100];
for(int b = 0; b < stobar.length; ...