Jan 1, 2010

Learning Java as a C++ Programmer

Primitive Data Types
  • char is 16-bit. byte is 8-bit. boolean corresponds to bool in C++.

  • All Java primitive types are signed.Why?
Casting
  • Java is more strongly typed than C++. No way to convert between boolean and integer types.
Operators
  • Java has two new operators, >>> and >>>=. Each of these performs a right shift with zero fill.

  • Java operators cannot be overloaded, in order to prevent unnecessary bugs
Struct and union
    No struct or union.
Arrays
  • Arrays are objects, defined by Type [].

  • Out of index accessing causes ArrayIndexOutOfBoundsException exception.

Classes

  • Can set default value of class data members




No comments: