answersLogoWhite

0


Best Answer

I'm not sure what you're asking. Do you mean when you declare/instantiate an array like this?

int[][] arr;

arr = {{1, 2, 3},{4, 5, 6}};

I think that's right.

***********************************

THIS IS INCORRECT

because you can assign constant values to array only at time of initialization.

Therefore above code will throw an error.

Correct way is:

int[][] arr = {{1, 2, 3},{4, 5, 6}};

thanx ..

itsabhinav123@gmail.com

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Declare and initialize 2D array in java using two statements- one to declare variable the other to initialize elements?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Declare a numerical variable precise and initialize it to the value 1.09388641?

double precise = 1.09388641;


Write a pseudocode statement that declares the variable total so it can hold integers Initialize the variable with the value 0?

Declare Real price=49.95 Display "the original price." Input item original price Display "price"


How do you declare and initialize constant arrays?

example in C: const int a [] = {10, 20, 40, 80};


How do you find factorial 5 in C programming?

to find the factorial we declare a variable n and initialize its value to 1 initiate a loop for example a for loop and multiply the numbers upto 5 code:- for(i=1,n=1;i<=5;i++) { n=n*i; }


Can you declare a variable with abstract keyword?

no it is not possible


How do you declare an integer?

datatype variable name;


What is variable declarations?

A variable declaration is a math or programming term. A variable is an unnamed component. In the problem the wording will declare what the value of the variable is.


How you declare a variable in c language?

you have to give a statement in the following syntax datatype variable;


Can you declare a static variable in a header file?

Yes.


Are you required to initiate a variable when you first declare it in php?

no


Is it possible to declare a variable with abstract keyword?

yes


How you can declare local variable?

variable exit within a function and curly braces is local variable int main() { int x; }