201671010139 2016-2017-2 syntax differences between JAVA and C languages

Source: Internet
Author: User

There are many similarities in the syntax of Java and C, but there are many differences.

One, the difference in the initial value

In the C language, it can be used without initialization.

In Java, the value must be initialized.

Two, the difference between abstract methods or abstract classes

The equivalent syntax of C language is "pure virtual function" and "abstract class"

Java uses the abstract keyword to modify a method or abstract class, and the final class cannot be inherited

Use abstract classes as base classes in an inheritance hierarchy, provide generic concepts, implement their abstract methods by subclasses, and abstract classes cannot be directly instantiated as objects

E.super The difference between keywords

The JAVA super keyword, which refers to the parent class object, is often used to call the parent class's constructor or general method

C language does not have super keyword

Third, data types and classes

Java is a fully object-oriented language, and all functions and variables must be part of the class. In addition to the basic data types, the rest are used as class objects, including arrays. Objects combine data and methods to encapsulate them in a class so that each object can implement its own characteristics and behavior. C + + allows functions and variables to be defined as global. In addition, the structure and union in C + + is removed in Java, eliminating unnecessary hassles.

Four, string

C does not support string variables, using a null terminator in a C program to represent the end of a string, in Java, strings are implemented using class objects (STRINR and StringBuffer), which are the core of the Java language, with the following advantages of implementing strings with class objects:

(1) The method of establishing strings and accessing string elements is consistent throughout the system;

(2) J3 the string class is defined as part of the Java language, not as an additional extension;

(3) Java string execution run-time check-out to help troubleshoot some runtime errors;

(4) The string can be connected by "ten".

 

201671010139 2016-2017-2 syntax differences between JAVA and C languages

Related Article

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.