Warum erhalte ich beim Drucken von Bytes (einem numerischen Datentyp) mithilfe eines Druckstreams Zeichen?Java

Java-Forum
Anonymous
 Warum erhalte ich beim Drucken von Bytes (einem numerischen Datentyp) mithilfe eines Druckstreams Zeichen?

Post by Anonymous »

Warum führt die Kompilierung des folgenden Codes zu einem ASCII-Codewert: GHI? Ich dachte, Byte sei ein numerischer Datentyp? Siehe Code unten:

Code: Select all

import java.io.*;

public class PrintStreamDemo {

public static void main(String[] args) {

byte c[] = {70, 71, 72, 73, 74, 75, 76};
// create printstream object
PrintStream ps = new PrintStream(System.out);

// write bytes 1-3
ps.write(c, 1, 3);

// flush the stream
ps.flush();
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post