In C and C + +, the sizeof () operator satisfies one of our special needs: the number of characters assigned to the data item.
In C and C + +, the most common application of size () is "porting." Different data may have different sizes on different machines, so programmers have to be very aware of how big those types are when it comes to sizing operations.
For example, one computer can hold an integer with 32 bits, while the other is saved with only 16 bits. Obviously, in the first machine, the program can save a larger value. As you might have thought, porting is a problem that makes C and C + + programmers a pain in the neck.
Java does not need the sizeof () operator to meet this need, since all data types are the same size on all machines. We don't have to think about porting problems--java is itself a "platform-independent" language.