I was always told how C is faster than Java, so I decided to write a few very basic programs to see how much slower it is (if at all) at using basic commands like if, for etc. I compiled my code, and Java was significantly faster (although, as always takes longer to compile). Does Java have some sort of extra stuff built into its for loop so that it can do this more efficiently or something?
Here's my code...
Code:
public class speed {
public static void main(String[] args) {
int count;
for( count = 0; count <= 1000000000; count++ ) {
}
System.out.print( "\n" +count+ "\n" );
}
}
and for C...
Code:
#include <stdio.h>
int main(void)
{
int count;
for( count = 0; count <= 1000000000; count++ ) {
}
printf( "\n%d\n" ,count );
return 0;
}
Also, does anyone know how to indent your code here? (Since I tried, but it ignores the spaces at the start of each line when you post).
Cheers.
Bookmarks