Benefits of Java

Source: Internet
Author: User

Java with the C differences in language:

C language and Java is actually very familiar with, the most direct difference is in with, one is a comprehensive to the process, one is object-oriented. And Java can be cross-platform. C language can not, but can directly manipulate the hardware, and generate machine code efficiency is high. C language more than one, pointers are the essence of C language, want to learn C language, pointers must learn. There is no pointer to Java.

in Syntax : Java is evolved from C + +, so Java is similar to the C language syntax.
in the management of memory :
C language in the use of a piece of memory, to manually release the memory, if not released, run long, the program will easily crash. Because of the need to explicitly return memory, the problem is more complicated when a function needs to return a piece of memory to the caller. So we should pay attention to this: (1) allocating memory in the caller, passing it as a parameter into the called function (2), allocating it in the called function, releasing it in the caller after use (3) Use the static variable in the called function, you can return the variable.
and Java basically do not consider the memory problem, if you want to use an object, new one can, the process is behind the JRE for the object classification of a certain memory, when the JRE found that you no longer use this object, he will automatically reclaim memory, that is, you just borrow things, do not return, Because with someone when your valet, you do not use the time to return the things, but this process is still there, but it is only the JRE.

The basic type used in the

syntax :
The C language has a number of basic types such as: (Boolean, Char, Byte, short, int, long, float, double,struct, Union, Enum) also has arrays, pointers, and so on.
in Java: Only (Boolean, Char, Byte, short, int, long, float, double) These 8 basic types and references.
in Inheritance: two languages support method overloading, C is multi-line inheritance, and Java is single-inheritance. dynamic, static binding :
in the C language, a function must be modified with virtual in order to allow the runtime to dynamically determine which function is called. The virtual keyword is automatically inherited to support polymorphism, and any member function that is not modified with virtual (including static) is statically bound, that is, at compile time, decide which version to invoke. In Java, all methods, except static, final, private, are bound to be handled dynamically.
Initial value : In the C language, it can be used without initialization, whereas in Java, the value must be initialized.
Abstract method or abstract class : the equivalent syntax of the C language is "pure virtual function" and "abstract class", and Java uses the abstract keyword to modify an abstraction 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.

Super : The JAVA super keyword, which refers to the parent class object, is often used to invoke the parent class's constructor or generic method, and C does not have the Super keyword.
this: both have, are only current objects
Package : C Language No, Java has the concept of the package, you can organize the class, easy to pack and deploy, but also conducive to class security.
There are many differences in the grammar, it is not listed, you can see that Java than the C language to streamline a lot, in the practical life is also very strong, C language is AH operation memory is relatively strong. That is to say, Java is better suited to work on the upper level, as long as we know the interface is good, and C language is in the network lower layer, to understand the protocol. In short, each has its own advantages, each with its own fields.

Benefits of Java

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.