Computer Science, asked by gill2754, 1 year ago

Multidimensional array declaration in java

Answers

Answered by Vivek111s
0
To declare an array, you need to tell it what type it is. Think of declaring a variable: it is the same concept: You need to tell Java if it's dealing with strings, numbers, or objects. Simply creating themultidimensional array doesn't actually do anything; let's look at how data actually gets into the array.
Answered by Oreki
2

\textsf{\Large\textbf{Multi-Dimensional Arrays}}

  \textsf{Muti-dimensional arrays represent 2D, 3D, ... arrays which are combinations of}\\\textsf{several earlier types of arrays.}\\\textsf{For example, a two dimensional array is combination of two or more (1D) one}\\\textsf{dimensional arrays. Similarly, a three dimensional is a combination of two or}\\ \textsf{more (2D) two dimensional arrays.}

  \textsf{\large \textbf{Creating a Two Dimensional Array}}

      \texttt{<data\_type>[][] array\_nam \hspace{-1em} e;}\\\texttt{array\_nam \hspace{-1em} e = new <data\_type>[x][y];} \\ \textsf{\hspace{13em} \textbf{or,}}

      \texttt{<data\_type>[][] array\_nam \hspace{-1em} e = new <data\_type>[x][y];}\\ \textsf{\hspace{13em} \textbf{or,}}

      \texttt{<data\_type> array\_nam \hspace{-1em} e[][] = new <data\_type>[x][y];}\\\textsf{\hspace{13em} \textbf{or,}}

      \texttt{<data\_type>[][] array\_nam \hspace{-1em} e = \{ \{ elementOne, elementTwo, ...\},}\\\texttt{ \:\hspace{14em} \{ elementOne, elementTwo, ...\}, }\\\texttt{ \:\hspace{14em} ... \hspace{12.2em} \}}

Similar questions