2015-04-20 15:36:01 -07:00
|
|
|
|
//: operators/Casting.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
|
|
|
|
|
public class Casting {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
int i = 200;
|
|
|
|
|
long lng = (long)i;
|
|
|
|
|
lng = i; // "Widening," so cast not really required
|
|
|
|
|
long lng2 = (long)200;
|
|
|
|
|
lng2 = 200;
|
|
|
|
|
// A "narrowing conversion":
|
|
|
|
|
i = (int)lng2; // Cast required
|
|
|
|
|
}
|
|
|
|
|
} ///:~
|