C vs Java /* This is a Java comment */ /* This is a C comment */ import java.lang.System; #include public class intover { public static void main(String[] args) { int main(int argc, char *argv[]) { int i, j; int i, j; j = 1; j = 1; for (i = 1; i <= 10; i++) { for (i = 1; i <= 10; i++) { j = j * 10; j = j * 10; System.out.println(j); printf("j = %i\n", j); } } } } } Java keywords abstract double int strictfp boolean else interface super break extends long switch byte final native sychronized case finally new this catch float package throw char for private throws class goto protected transient const if public try continue implements return void default import short volatile do instanceof static while C keywords auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while Java is an object oriented language and C is not, so C does not include the keywords related to classes abstract final interface protected this class implements new static extends instanceof private super C uses functions called signals to handle exceptions, so C does not include the keywords relating to exceptions catch finally throw throws try Finally, C does not have a "character string" data type. The programmer creates character strings using arrays of bytes. However, the C keywork "char" (rather than byte) is used to declare a byte. The C declaration "char a;" declares "a" to be a small signed integer with a range from -128 to +127. The following keywords have identical meanings in C and Java break do for long void case double goto return while continue else if short default float int switch The following keywords have similar functions Java byte protected boolean import private-static C char static int #include static C includes the following keywords and features. 1. The keyword "struct" is used to define more complex data structures 2. THe keywords "signed" and "unsigned" allow for the declaration of unsigned integers (integers that are always greater then or equal to zero). 3. The C preprocessing directives "#include" (like "import") and "#define" (to substitute a character string for any identifier in the program). 4. The operators "&" (address operator) and * (indirection operator) allow for the manipulation of memory addresses. For example: #include main() { int i = 16; int *pi = &i; /* pi is the 32-bit address of variable i */ printf("%8.8x\n", pi); /* printed bfa9f818 */ printf("%8.8x\n", *pi); /* printed 00000010 */ }