This question already has answers here:
Java ArrayList to Kotlin Array
(4 answers)
Closed 1 year ago.
So, I try to make a line chart using AAChartModel. I have ArrayList in my code. But in AAchartModel they used an arrayOf instead of ArrayList.
So My Question is, how do I convert from ArrayList to arrayOf ?
arrayOf() returns just an Array. So you can call arrayList.toTypedArray()
This question already has answers here:
How do I declare and initialize an array in Java?
(31 answers)
Closed 2 years ago.
Can i ask whats the meaning of the input "52" on [], because if i delete the 52 the program wont run.
ArrayList<String> playerCard[]= new ArrayList[52];
The 52 tells the compiler how large the array is.
This question already has answers here:
How is this illegal
(5 answers)
Array error in java [duplicate]
(3 answers)
Error in simple array... How to fix [duplicate]
(1 answer)
Closed 5 years ago.
New to Java, this is part of a practice question from a question in my book where i'm learning java. I think I've traced the error to the array, in particular to the initialization but i'm not sure how to fix it, why isn this correct?
int[][][] arr;
arr= new int[20][][];
arr[0] = new int[1][];
arr[0][0] = new int[10]{1,1,-1,-1,-1,1,-1,-1,1,-1};
When you supply an array initializer expression, you can't specify the array dimensions too.
You can use :
arr[0][0] = new int[]{1,1,-1,-1,-1,1,-1,-1,1,-1};
When i run it in eclipse it says Cannot define dimension expressions when an array initializer is provided., i think that's really clear for an error message. It means you can either specify the dimensions or the initialize the array. But NOT both at the same time.
Change to:
inputs[0][0] = new int[]{1,1,-1,-1,-1,1,-1,-1,1,-1};
This question already has answers here:
How do I declare and initialize an array in Java?
(31 answers)
Closed 5 years ago.
I am trying to declare and instantiate an array named 'canines' that had 25 elements and will hold 'dog' objects...
Is this the best way to do this or is there another formate that would be more correct?
canines[25] = Dog
Dog[] canines = new Dog[25];
Have a look at some of the many online java resources
This question already has answers here:
Syntax for creating a two-dimensional array in Java
(13 answers)
Closed 6 years ago.
I am trying to read an image's pixels and fill them in a 2d array; however, I don't know how to declare a global array? any help please?
int [][] arr = new int[height][width];