int a=1;
int b=2;
float c = 5.5f;
double d = 6.78; // this is about as amusing as code gets

int answer = a + b; // normal addition
answer = (int)c + (int)d; // demoting variables using a cast
c = a; // no cast needed when promoting

c = (float)d; // need to demote a float to be a double

String text = "moo"; // notice the ""!
String moreText = text; // moreText will get the value "moo"

You can get a copy of the java file here.

next summary >>

 
Basics
Menu
Search