This is some information on the Java 6 certification that I prepare. This information is not very well structured and it is most of the time an answer to the questions that come when I read the SCJP 6 book (Bates and Sierra). *** AS OF 5 OF MARCH 2010, I AM SCJP 6.0 ***

Thursday, January 7, 2010

5 - short and char

    public static void main(String[] args) {
        short a=5;
        a+=10;
        a%=2; // OK
        // a=a+10; // does not compile - possible loss of precision
        a=(short)(a+10);
        char b=5;
        b+=10;
        // b=b+10; // does not compile - possible loss of precision
        b=(char)(b+10);
        b%=2; // OK 
    }

No comments:

Post a Comment

Followers