Java and C different points

Source: Internet
Author: User
Tags constant definition exception handling garbage collection goto

1. Java has no preprocessing directives. (such as the #define in C, #include, #ifdef等). The constant definition in C is replaced with static final in Java.

2. There are no global variables in C in Java.

3. The size of the main type in Java is OK, whereas the size of the main type in C is related to the platform.

4. There is no pointer in Java, it uses a similar handle to replace the pointer, but Java does not allow the handle to add and subtract, do not take the address operator and so on.

5. Java has a garbage collection mechanism and does not need to free up its own space.

6. Java does not have a goto statement. Java adds exception handling and label break and continue statements based on the control statements provided by C. These can replace the role of Goto.

7. c requires that the definition of all local variables used in a method or block be defined at the very beginning of the method or block, and Java allows these definitions to appear anywhere in the method or block.

8. Java does not require that the function be defined before calling a function, which can be defined after the call point. and C has this requirement.

9. Java does not support the strut and union types in C. Java support method overload.

10. Java does not support the enum keyword in C.

11. Java does not support the ability to bitfields in C.

12. Java does not support typedef for C.

13. Java does not support method pointers for C.

Java does not support variable parameter tables for C.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.