R
Razvan
Hi !
The following code does not compile (as expected):
class SimpleJava
{
public static void main(String args[])
{
System.out.println("SimpleJava ....");
byte bb = 0;
bb = bb + 1;
System.out.println("bb = " + bb);
}
}
While the following one is compiling:
class SimpleJava
{
public static void main(String args[])
{
System.out.println("SimpleJava ....");
byte bb = 0;
bb += 1;
System.out.println("bb = " + bb);
}
}
The += operator is specific to each primitive, so it "know" how to
work with integers. The operator + is generic so a cast is necessary
?!!
Any other logical explanation ?
Regards,
Razvan
The following code does not compile (as expected):
class SimpleJava
{
public static void main(String args[])
{
System.out.println("SimpleJava ....");
byte bb = 0;
bb = bb + 1;
System.out.println("bb = " + bb);
}
}
While the following one is compiling:
class SimpleJava
{
public static void main(String args[])
{
System.out.println("SimpleJava ....");
byte bb = 0;
bb += 1;
System.out.println("bb = " + bb);
}
}
The += operator is specific to each primitive, so it "know" how to
work with integers. The operator + is generic so a cast is necessary
?!!
Any other logical explanation ?
Regards,
Razvan