casting array of array question???


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: casting array of array question???

  1. #1
    Xasting Guest

    casting array of array question???


    Hi all,

    Here's the prob ...

    public class castIt {
    public static void main(String args[]) {
    char ch = 5;

    byte b[][] = new byte[3][3];
    b[1][2] = (byte) ch;

    for(int i = 0; i < 3; i++) {
    System.out.println( );
    for(int j = 0; j < 3; j++) {
    System.out.print(" " + b[j][i]);
    }
    }
    System.out.println();
    }
    }

    output is:
    000
    000
    050

    required output:
    000
    000
    0?0

    I want the smilly face character (char ch = 05 ... note this is better
    viewed in a dos window some IDE's will not display these ascii characters.
    Hope this makes sense... and yes I do want the array of arrays to be of type
    byte.

    ThanksInAdvance
    Xasting.


  2. #2
    prosper Guest

    Re: casting array of array question???


    "Xasting" <xasting@yahoo.com> wrote:
    >
    >Hi all,
    >
    >Here's the prob ...
    >
    >public class castIt {
    > public static void main(String args[]) {
    > char ch = 5;
    >
    > byte b[][] = new byte[3][3];
    > b[1][2] = (byte) ch;
    >
    > for(int i = 0; i < 3; i++) {
    > System.out.println( );
    > for(int j = 0; j < 3; j++) {
    > System.out.print(" " + (char)b[j][i]);
    > }
    > }
    > System.out.println();
    > }
    >}


    put a char to change the cast before your byte array.
    smile face is 2 in value in my jdk1.2.2


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center