Vishal Joshi

Greenhorn
+ Follow
since Apr 21, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vishal Joshi

Final code for 3 dimensional array

yes i did it
i got the answer


[ May 05, 2008: Message edited by: Vishal Joshi ]
How to print the following assigned array using for loop


int [][][] j = new int [4][3][2];

j [0][0][0] = 000;j [0][0][1] = 001;
j [0][1][0] = 010;j [0][1][1] = 011;
j [0][2][0] = 020;j [0][2][1] = 021;

j [1][0][0] = 100;j [1][0][1] = 101;
j [1][1][0] = 110;j [1][1][1] = 111;
j [1][2][0] = 120;j [1][2][1] = 121;

j [2][0][0] = 200;j [2][0][1] = 201;
j [2][1][0] = 210;j [2][1][1] = 211;
j [2][2][0] = 220;j [2][2][1] = 221;

j [3][0][0] = 300;j [3][0][1] = 301;
j [3][1][0] = 310;j [3][1][1] = 311;
j [3][2][0] = 320;j [3][2][1] = 321;
i tried the following code and i got 3840 lines of output

I need only elements of my array to get displayed only once

public class tp
{
public static void main(String [] args)
{
byte [] [] b = new byte [2] [1];
b [0][0] =1;
b[1][0] = 2;
System.out.println(b[0][0]);
System.out.println(b[1][0]);

int [][][] j = new int [4][3][2];

j [0][0][0] = 000;j [0][0][1] = 001;
j [0][1][0] = 010;j [0][1][1] = 011;
j [0][2][0] = 020;j [0][2][1] = 021;

j [1][0][0] = 100;j [1][0][1] = 101;
j [1][1][0] = 110;j [1][1][1] = 111;
j [1][2][0] = 120;j [1][2][1] = 121;

j [2][0][0] = 200;j [2][0][1] = 201;
j [2][1][0] = 210;j [2][1][1] = 211;
j [2][2][0] = 220;j [2][2][1] = 221;

j [3][0][0] = 300;j [3][0][1] = 301;
j [3][1][0] = 310;j [3][1][1] = 311;
j [3][2][0] = 320;j [3][2][1] = 321;

System.out.println(j[3][0][1]);
int jw =0;
for (int j1=0 ;j1<j.length ;j1++ )
{
for(int j2=0 ; j2 < j[j1].length;j2++)
{
for (int j3=0; j3 < j[j1][j2].length ;j3++ )
{
for (int j4=0; j4 < j[j1][j2][j3] ; j4++)
{
System.out.println(j[j1][j2][j3]);
jw++;
}

}
}
}
System.out.println(""+jw);
}
}
can you please explain me / give diagramatic view of code

byte b2 [] [] [] [] = new byte [2][3][1][2];
hi friends,
I am bit confuzed with multi dimensional array
if i write
byte [] [] b = new byte [2][1];

it means i have created 2 arrays , each has a capacity of 1 element
then what will be under the case of

byte [] [] b = new byte [1][2];

Thanks in advance for your precious reply
Hi Bert ,

Thanks for your guidance.Thank you very much.
Thanks Nabila for the information.
Hi ALL,

Can you please tell me which is the best Book for SCJP1.4 Certification and also how much time is requires to be thorough for Certification Exam.