A comparison between C # and Java

Source: Internet
Author: User
Tags class definition comparison

C # is the weapon that Microsoft uses to compete with Java, because the two are surprisingly similar to a large extent, but there are also many different places, the so-called "see the difference in nuances". So where are the similarities and differences between the two? From today onwards, we will compare the features of C # and Java from various angles, hoping to help friends who are learning and using C #.

1. Overview of C # and. NET Platforms

June 2000, Microsoft releases the C # language and. NET platform. C # language is a strong type, object-oriented language, it has a simple syntax, strong expression of the characteristics, and the. NET platform is composed of Microsoft. NET Plan "is the cornerstone.

. NET platform's core includes two aspects, on the one hand is the famous common language running machine (Common Language Runtime), although this noun has been obscure, but you can compare it with the Java Virtual machine, both accomplish the task is roughly the same On the other hand is a bunch of general-purpose library functions that can be invoked in multiple languages, and compile all produce a common intermediate language (intermediate Language), which can also be likened to Java bytecode, although in some different ways.

2, C # and Java

The following is a simple list of C # and Java similarities, although here we focus on the differences between C # and Java, but it is also necessary to understand the similarities.

Both are compiled into Cross-platform, Cross-language code, and the code can only run in a controlled environment

Automatically reclaims garbage memory and eliminates pointers (pointers can be used in C #, but must be marked with unsafe keywords)

Do not require a header file, all code is limited to a scope by "package (Package)", and because there is no header file, it eliminates the cyclic dependency of the class definition

All classes are derived from objects, and memory must be allocated using the New keyword

Use object locking to support multithreading

Has the concept of an Interface (interface)

Inner class

Inheriting a class is not inherited with a specific access right;

No global function or constant, all must belong to class;

The array or string has its own length calculation and boundary checking;

Use only "." operator, no "-$#@62;" and "::";

"Null", "Boolean" and "bool" became keywords;

Any variables are initialized before use;

You cannot use integers to return to an if conditional statement, you must use a Boolean value;

"Try" module can have "finally";

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.