0

What is output of this code?

public class Program { public static void main(String[] args) { int[ ][ ] sample = { {1, 2, 3}, {4, 5, 6} }; int x = sample[0][0]; System.out.println(x); } }

3rd Nov 2019, 2:31 PM
Sarvar Khidirov
Sarvar Khidirov - avatar
5 Respostas
+ 2
Did you try to get this? This is two dimensional array. Here sample[0][0] means index i = 0, index j = 0 so value will be 1; Check this:- https://www.google.com/amp/s/www.geeksforgeeks.org/multidimensional-arrays-in-java/amp/
3rd Nov 2019, 2:33 PM
A͢J
A͢J - avatar
0
:)
3rd Nov 2019, 2:32 PM
Sarvar Khidirov
Sarvar Khidirov - avatar
0
Correct 👍
3rd Nov 2019, 2:33 PM
Sarvar Khidirov
Sarvar Khidirov - avatar
0
Sarvar Khidirov If you know that why are you asking? Please don't waste our time.
3rd Nov 2019, 2:39 PM
A͢J
A͢J - avatar
0
If you only want to know the output, you can test the code in Code Playground. If you want the explanation for it, then ask for explanation rather than "What is the output of this code?". BTW you should've tagged Java in your question. For future reference, please follow this guide to posting a question 👍 https://www.sololearn.com/Discuss/333866/?ref=app
3rd Nov 2019, 3:14 PM
Ipang