aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes array -please explain the output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "array -please explain the output" Watch "array -please explain the output" New topic
Author

array -please explain the output

alwin das
Ranch Hand

Joined: Sep 23, 2005
Posts: 32


why am i getting error as imcompatible datatypes there?i can asign b3 to two diamensional and 4-d array so why not at for 3-d array.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
b2[1][2][0]


b2[1][2][0] is a byte array and b3 is a byte.

Note that b[0][1] and b2[1][2][1][0] are bytes.
[ June 13, 2006: Message edited by: Keith Lynn ]
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809


At Line 1, LHS>>>> b[0][1] primitive type... RHS>>>> b3 byte primitive type. One byte can be assigned to another byte type. CORRECT.

At Line 2, LHS>>>> b2[1][2][0] is 1-D Array... RHS>>>> b3 byte primitive type. One byte can't be assigned to 1-D byte array. WRONG

At Line 3, LHS>>>> b2[1][2][1][0] is primitive type... RHS>>>> b3 byte primitive type. One byte can be assigned to another byte type. CORRECT.

At Line 4, LHS>>>> b2[1][2] is 2-D byte array... RHS>>>> b is also 2-D byte array. Again can be assigned. CORRECT.

PLZ view a similar post here...

http://www.coderanch.com/t/255494/java-programmer-SCJP/certification/scjp-qtn-Mult-dimensional-array

regards

NaK


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
alwin das
Ranch Hand

Joined: Sep 23, 2005
Posts: 32
sorry i didnt get that ..

even b2[1][2][1][0] this is a array and b2[1][2][0] is a array

so what is the difference ?why am i getting error only atb2[1][2][0]
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809


Because u r assigning b3 which is primitive to b2[1][2][0] which is one dimentional byte array.

CAN'T ASSIGN PRIMITIVE TO A BYTE ARRAY
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809

Originally posted by alwin das
even b2[1][2][1][0] this is a array and b2[1][2][0] is a array


b2[1][2][1][0] is not an array. Its a byte primitive type.

b2 is a 4-d array.
b2[1] is 3-D array
b2[1][2] is 2-D array.
b2[1][2][1] is 1-D array.
and b2[1][2][1][0] is not an array rather its a primitive type bye.
alwin das
Ranch Hand

Joined: Sep 23, 2005
Posts: 32
nasim thanx a lot for that explanation.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: array -please explain the output