• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

array -please explain the output

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nasim thanx a lot for that explanation.....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic