Java and C are object-oriented languages. That is, they all enable object-oriented ideas (packages, step by way, polymorphism). Since C is compatible with C-language users, it is compatible with C, which makes it only a C language with a class, and there are fewer effects that the object-oriented thoroughness! Java is a complete object-oriented language, which is clearer, smaller, and more easy to learn. It is based on the in-depth study of various programming languages, and has fundamentally solved the inherent defects of C . Similarity of Java and C is more than different, but the two languages have a few major differences make Java easier to learn, and the programming environment is simpler. I can't fully list the differences here, only listed more distinctive differences: 1. The Pointer Java language allows the programmer unable to find a pointer to directly access the memory without a pointer, and add an automated memory management function, effectively preventing the pointer operation error in the C / C language, such as the system crashes caused by the wild pointer. But not saying that Java does not have a pointer, the virtual machine still uses a pointer, but the outsiders are not allowed. This is conducive to the safety of the Java program. 2. Multiple inheritance C supports multiple inheritance, this is a feature of C , which allows multiple parent classes to derive a class. Although multiple inheritance is strong, it is not easy to use, and it is not easy to achieve it. Java does not support multiple inheritance, but allows a class to inherit multiple interfaces (Extends Implement), enabled C multiple inheritance functions, and avoids many inconveniences caused by multiple inheritance implementations in C . 3. Data types and class Java are the language of fully object-to-object, all functions and variables must be part of the class. In addition to the basic data type, the rest is used as class objects, including arrays. The objects combine data and methods to encapsulate them in the class so that each object can realize its own features and behavior. C allows the function and variables to be defined as global. In addition, the structure and joints in C / C are canceled in Java, eliminating unnecessary trouble. 4. Automatic Memory Management Java program All objects are built on the memory stack with the New operator, which is similar to the C New operator. The following statement is built by an object that has established a class read, then calls the Work method for the object:
Read r = new read ();
R.Work ();
The statement read r = new read (); an instance of a READ is established on the stack structure. Java automatically performs a useless memory recycling operation, does not require programmers to delete. And c19 must release memory resources by the program, increase the negative throw of program designers. Java When an object is not used, the useless memory recovery will give it a label to delete. The Used Memory Recycling Program in Java is run in the thread mode, using free time. 5. Operator is overloaded Java does not support operator overload. The operator overload is considered to be a highlighted feature of C10, although the class can be achieved in Java, but the convenience of the operator overload is still lost. The Java language does not support operator overloading to keep Java languages as simple as possible. 6. Pre-processing functions Java does not support pre-processing. C / C 10 has a pre-program stage in the compilation process, that is, well-known preprocessors. The preprocessor provides developers to provide convenience, but increases the complexity of Ding compilation. The Java virtual machine does not have a preprocessor, but it is similar to the introduction statement (IMPORT) with the C-10 pre-processor. 7. Java does not support the default function parameters, and C 10 supports in C, the code organization is in the function, the function can access the program's global variable. C 10 Ten has added a class, providing a class algorithm, which is a function connected to the class, and the C10 type method is very similar to the Java class method. However, because C is still supporting C, so you can't stop C 20 development The use of functions, resulting functions, and method mixing makes the program more confusing. Java has no functions, as a more pure object-oriented language than C, Java forced developers include all routines, in fact, using methods to implement routine can motivate developers better organize encoding . 8 String C and C 10 do not support string variables, using NULL terminator in the C and C ten programs, the end of the string represents the end of Java, the string is implemented with the Strinr and StringBuffer, These objects are the core of the Java language, and the use of class objects have the following advantages: (1) Creating a string and accessing a string element throughout the system; (2) J3 Yang string class It is defined as part of the Java language instead of an additional extension; (3) Java string performs runtime empty, which can help eliminate errors that occur when running; (4) Use "ten" to string Perform a connection operation. 9 "GOTO statement" terrible "GOTO statement is C and C " relics ", it is a legal part of the language technology, reference the goto statement causes the chaos of the program structure, it is not easy to understand, GOTO sentences should be used for unconditional transfer Subprogo and multi-structure branch technology. Given that the GOTO statement is provided in view of the wide ground, it specifies that Goto is used as a keyword, but does not support its use, so that the program is simple and easy to read. L0. Type conversion in C and C19 There is sometimes the implicit conversion of data types, which involves automatic mandatory type conversion problems. For example, the floating point value can be given to integer variables in C19, and remove the mantissa. Java does not support C19 Automatic mandatory type conversion, if needed, must be reversed by program explicitly. 11. Exceptions in an exception Java is used to capture exception events, enhance system fault-tolerant ability try {// may generate exceptional code
} catch (exceptiontype name) {
//deal with
}
The ExceptionType indicates an exception type. And C does not have such a convenient mechanism.