高分求救,关于byte转换char问题
limop 2007-01-11 12:00:07 package add;
import java.io.*;
/**
* <p>Title: addxy</p>
*
* <p>Description: addxy</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: BNU</p>
*
* @author 苏君福
* @version 1.0
*/
public class Test_Add {
public Test_Add() {
}
static int ARRAY_MAX_VALUE = 10;
static int ADD_XY_COUNT = 10000;
static int x,y,z;
public static void main(String[] args) throws IOException {
Test_Add test_add = new Test_Add();
for(int i=0;i<ADD_XY_COUNT;i++){
byte[] number1 = new byte[ARRAY_MAX_VALUE];
byte[] number2 = new byte[ARRAY_MAX_VALUE];
char[] c = new char[ARRAY_MAX_VALUE];
/* 读第一个数 */
System.in.read( number1);
c = (char)number1;
System.out.println("number1 = " + c);
x = number1;
System.out.println("x = " + x);
/* 读第二个数 */
System.in.read(number2);
// c = (char)number2;
System.out.println("number2 = " + c);
// y = number2;
System.out.println("y = " + y);
/* 计算X+Y */
AddXY addxy = new AddXY();
z = addxy.AddXY(x, y);
System.out.println(" x + y = " + z);
}
}
}
为什么 c = (char)number1;
x = number1;
这两行会出现类型错误呢?请教高手!