DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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


Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links