Sunday, September 5, 2010

C # and Java relationship and differences between the two languages

In the twenty-first century era, in many areas of software development, Java language and C # language is essential, too, has gradually improved, and a wide range of applications, Java language and C # language is a kind of surface to the target language, but Java programs and C # programs and links the differences between them lie? The following examples of use. Here are two examples of the language program. 1.Java language of the basic procedures: ...

Developed in the twenty-first century, today, in many areas of software development, Java language and C # language is essential, too, has gradually improved, and a wide range of applications, Java language and C # language is an object-oriented language, but Java programs and C # programs and links the differences between them lie? The following examples of use.

Here are two examples of the language program.

1.Java language of the basic procedures:
Import java.util .*;
Package HelloJava (
Public class Message (
Public static void main (String [] args) (
System.out.println ("Welcome to Java World");
)
)
)

2.C # language, the basic process:
Using System;
Using System.Collection.Generic;
Using System.Text;
Namespace HelloAccp (
Class Program (
Static void Main (string [] args) (
Console.WriteLine ("Hello Accp. NET");
Console.ReadLine ();
)
)
)
According to these two basic procedures, we distinguish between what Java language programs and the various C # language program.
First, import the package keyword.
In Java, if you import other package, should use the import keyword in C #, using the using keyword to refer to other namespaces, but the role of the two the same.
Second, the namespace keyword.
namespace (namespace) is the C # code in the organization, rather package (package) is used in Java, their role is to be closely related to some code in the same namespace, which greatly improve the management and efficiency .

3, Class keyword.
In both Java and C # in that category with the class keyword, and the preparation of any code should be included in a class inside. Class to be included in a namespace or a package, but the difference is in Java, the required class name and source file name must be the same, but C # Not required.

4, Main different methods.
C # in the Main () method, and Java in the main () method is the same role, are running the first step. However, in Java main () method and only one lower-case first letter written, and C # in the Main () method of the first four letters will be capitalized and written. Are:
Static void Main (string [] args) ()
static void Main () ()
Static int Main (string [] args) ()
static int Main () ()

5, input and output method.
In Java, the output method: System.out.println (); and another System.out.println (to the output value);
Input method: creating Scanner objects, such as Scanner sa = new Scanner (); then the object point method. Such as String name = sa.nextString ();
In C # in the output method: Console.WriteLine (); and Console.WriteLine (to the output value); and an unique way C # Console.WriteLine ("format string", variable list);
Input method: string name = Console.ReadLine ();
These are summed up in my learning differences, there may be loopholes to be a reference to give us hope that we learn the two languages together to explore their knowledge of them.

No comments:

Post a Comment