Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array -please explain the output

 
alwin das
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
alwin das
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nasim thanx a lot for that explanation.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic