create 2-D character array in java [duplicate] - java

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';
...

Related

Kotlin : How to convert Array<List> to arrayof? [duplicate]

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()

Whats the purpose of inputted address inside []? [duplicate]

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.

Error with array initialization [duplicate]

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};

Correct way to instantiate an array in java? [duplicate]

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

How to declare a call a 2d array in java? [duplicate]

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];

Categories

Resources