(short)a=1 can't compiled?
Deal all: I am new to java. If i type as below:short a=1;b=2; ->can compiledshort a,b; a=1;b=2 -> can't compiledshort a,b;a=(short)(1);->can't compiled can anyboby tell me Why?Thanks!!!
[266 byte] By [
wonwoei] at [2007-9-26 1:25:06]

Hi,A semicolon (;) is missing on the end of this line:short a,b; a=1;b=2The last one should compile. I recommend to put the statements on different lines. Also, you shouldn't explicitly cast the "1" to a short.
Sorry,i mistyped. my origin code as below: 1) :short a=1,b=2; 2) short a,b;a=1;b=2;3) short a,b;a=(short)(1);b=(short)(2);I use JDK 1.3Thank yous reply! But I still have problem!!!
try this way
class test
{
//short a=1,b=2;// ->can compiled
/*short a,b;
test()
{
a=1;
b=2; //->// can't compiled
}*/
short a,b;
test()
{
a=(short)(1);//->can't compiled
}
}
hi,
i was able to compile the below statements below with jdk 1.3.
short a=1,b=2; //->can compiled
short a,b; a=1;b=2;// -> can't compiled
short a,b;a=(short)(1);//->can't compiled
if these does not work with ur version, please do send us ur error.
regards,
shiva