Comperison of C and Java

OverView

Because C is machine's native language, the program written by c is faster than by Java.
why java is slower than C?
this is because Java is run through VM(Virtual Machine).
When I learned about programming language for the first time, I start with Java.
for me, It is wrong choice.
Java is hard for beginner.
I think I had to start with C.
When I use C, I have to care about memory,pointer… It is confusing,but very good for getting know about PC.

Difference between Java and C++

c++ java
#include import
Inheritance childClass:ParentClass childClass extends ParentClass
Override of method nothing to do @override
class should be end with, }; } (no need for ;)
destractor Class::~Class() java do automatically
pointer * & none.
console output #include <stdio.h> printf(""); System.out.println("");
String(text) string char* String 
size of char 1byte 2byte
constant const final
size of type sizeof(type)=*byte type.SIZE=*bit
overload of operator available unavailable
structure struct public final class is alternative for structure1

Numbers

in Java , you cannot use "unsigned" qualifier.

c++ java
char 1byte -128~127 2byte 0~655352
unsigned char 1byte 0~255 unsigned is not exist in java
byte 1byte -128~127 1byte -128~127
short 2byte -32768~32767 2byte -32768~32767
unsigned short 2byte 0~65535 unsigned does not exist in java

Primitive Data Types-The java tutorials

Minimum and maximum value of each type.

In c++,you need to include limits.h
when you use min or max value of floating point numbers,include float.h

c++ java
byte Byte.MAX_VALUE(127)
Byte.MIN_VALUE(-128)
char SCHAR_MIN(-128)3 Character.MIN_VALUE(\u0000)4
SCHAR_MAX(127) Character.MAX_VALUE(\uFFFF)
unsigned char UCHAR_MAX(255)
short SHRT_MAX(32767) Short.MAX_VALUE(32767)
SHRT_MIN(-32768) Short.MIN_VALUE(-32768)
unsigned short USHRT_MAX(65535) same as Characer
int INT_MIN(-2147483648) Integer.MIN_VALUE(-2147483648)
INT_MAX(2147483647) Integer.MAX_VALUE(2147483647)
unsigned int UINT_MAX(-1)=0xffffffff5
long LONG_MIN(-214748368) Long.MIN_VALUE(-9223372036854775808)
LONG_MAX(214748367) Long.MAX_VALUE(9223372036854775807)
unsigned long int ULONG_MAX(-1=0xffffffff)
long long int (8byte) LLONG_MIN(0)
LLONG_MAX(-214748368=0xffffffffffffffff6) 7
unsigned long long ULLONG_MAX(-1=0xfffffffffffffff8)
float FLT_MIN(2.225074e-038) Float.MIN_VALUE(1.4E-45)
FLT_MAX(3.402823e+308) Float.MAX_VALUE(3.4028235E38)
double DBL_MIN (2.225074e-308) | Double.MIN_VALUE( 4.9E-324)
DBL_MAX(1.797693e+308) Double.MAX_VALUE(1.7976931348623157E308)

Array

c++ java
Initialization of array int a[16]={1,2,…}; int[] a={1,2,..};(don't white number within the []nt a[] is also ok)
Initialization of array int a[16]; int[] a = a(16);
length of array "for each" or "sizeof()" array.length
when the argument is array void method(int *_a); void method(int[] _a);
looping through the array for (int i = 0;i < num ;i++) for (int i = 0;i < array.length;i++)
Bibliography
en.gif en
ja.gif ja


edit
サポートサイト Wikidot.com