Java Language Basics
Java syntax has many similarities to C/C++.
- All variables must be declared
- Syntax, comments, control structures are the same
But there are some differences
- No malloc or free - it has automatic garbage collection
- No pointers - designers felt pointer arithmetic not robust or safe
- Can declare variables almost anywhere as needed.
- No struct, union, enum, typedef from C - it has classes and objects instead.
- Java characters are based on 16--bit wide Unicode Worldwide Character Encoding rather than the usual 8--bit wide ASCII. This allows full support of all alphabets and hence all languages
- Primitive types for integers and floats have machine independent semantics
- Booleans in Java have value “true” or “false” (not 0, 1, . . .)