This question already has answers here:
Syntax for creating a two-dimensional array in Java
(13 answers)
Closed 3 years ago.
I want to create a character array like this one below:
character array
i am unable to find a method . Please help me out. Beginner in java
char[][] x = new char[][]{};
x[0][1] = 'c';
...
This question already has answers here:
Difference between int[] array and int array[]
(26 answers)
Closed 5 years ago.
Like int [] i or int i [] is there any difference
I'm curious
No, int[] i is the same as int i[], but the latter one is discouraged.
See the official documentation on Arrays:
However, convention discourages this form; the brackets identify the array type and should appear with the type designation.
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:
Is there a longer than int Java List?
(3 answers)
Using a long as ArrayList index in java
(7 answers)
Closed 7 years ago.
I want to have a big ArrayList, so its index would go beyond int, how or what can I use for that?
I already checked that Vector does have the same issue, any ideas?