Array problem

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
vanik34
Posts: 4
Joined: Thu Jun 18, 2015 12:35 pm
Contact:

Array problem

Post by vanik34 »

can you help me to understand what is happening here
it's compiles ok

String ejgStr[] = new String[][]{{null},new String[]{"a","b","c"},{new
String()}}[3] ;
:(

vanik34
Posts: 4
Joined: Thu Jun 18, 2015 12:35 pm
Contact:

Re: Array problem

Post by vanik34 »

Never mind it's create a two dimensional array and then return the [x] position
here is a more readable example
int[] eArr3 = new int[][]{{57},{1},{2},{3}}[0];

System.out.println(eArr3[0]);

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Array problem

Post by admin »

The lines of code that you have mentioned above will not compile because there is one set of [] missing in the variable declaration part. It should be int[][] eArr3 or int[] eArr3[] instead of int[] eArr3.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 27 guests