10 Things Every Java Programmer Should Know About Ruby | [ Prev | Home | Next ] |
C Code (Weak)#include <stdio.h>
extern float two();
int main() {
float x = 1.5 + two();
printf("%f\n", x);
printf("%d\n", x);
return 0;
}
|
Java Code (Strong)public class Main {
public static
void main (String args[]) {
double x = 1.5 + Two.two();
System.out.println(x);
}
}
|
int two() { return 2; }
|
public class Two {
public static int two() {
return 2;
}
}
|
Outputnan 0
|
Output3.5
|
O'REILLY® OSCON 2005 | Copyright 2005 by Jim Weirich (All Rights Reserved) |