java!!!分析下列非法语句出错原因
来源:百度知道 编辑:UC知道 时间:2024/06/29 03:04:53
Static int ARRAY_MAX_VALUE = 128;
byte b_Byte = ARRAY_MAX_VALUE;
short s_Short = b_Byte;
char c_Char = b_Byte;
b_Byte = 0x1234;
int i_Int = s_Short;
s_Short = 1.25F;
long l_Long = i_Int;
i_Int = 12345L;
float f_Float = (float)l_Long;
double d_Double = 0.5E-4;
i_Int = (int)d_Double;
s_Short = (short)i_Int;
i_Int = l_Long;
Boolean bool_Boolean;
i_Int = (int)bool_Boolean;
byte[] b_Array = new byte[b_Byte];
char[] c_Array = new char[b_Byte];
b_Array = (byte)c_Array;
帮你改了下,有些能修改的就修改了,不能修改的就注释了。
public class Test {
public static int ARRAY_MAX_VALUE = 128;
public static void main(String[] args) {
byte b_Byte = (byte)ARRAY_MAX_VALUE;
short s_Short = b_Byte;
char c_Char = (char)b_Byte;
b_Byte = (byte)0x1234;
int i_Int =(int) s_Short;
s_Short = (short)1.25F;
long l_Long = i_Int;
i_Int = (int)12345L;
float f_Float = (float)l_Long;
double d_Double = 0.5E-4;
i_Int = (int)d_Double;
s_Short = (short)i_Int;
i_Int = (int)l_Long;
Boolean bool_Boolean=true;
//i_Int = (int)bool_Boolean; 不可转换
byte[] b_Array = new byte[b_Byte];
char[] c_Array = new char[b_Byte];
// b_Array = (byte)c_Array; 一个是数组类型,一个是值 不能赋值
}
}
在eclipse写个类跑一下就可以了
byte b_Byte = ARRAY_MAX_VALUE;
不能将 int 型 隐式转换为 byte型,需要强制转换;
char c_Char = b_Byte;
不能将 byte 型隐式转换为 char 型,需要强制转换;
b_Byte