Compiler Designing W10L1805

Java Coercions

  • Conversion from one type to another.
  • Widening, (example int to float) can be implicitly and narrowing, (example float to int)is to be done explicitly.
  • bool has no coercion or cast.
  • Many times coercion can result in surprising behavior. Example of PL/I here:
A = '123';
B = '123'
C = A + B    //C would have three blanks in it as a result, + will force A and B to convert in             //integers, and because C should have a length of 6, and the resulting sum would              //be placed at 
            //the last, the initial three letters will be chosen having blanks.

Help to improve or comment as you wish

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s