Home > Java > JavaBase > body text

Is there any difference between c syntax and java syntax?

青灯夜游
Release: 2019-12-27 14:29:16
Original
2907 people have browsed it

Is there any difference between c syntax and java syntax?

There are grammatical differences between C language and java. The difference is:

1. C language can directly operate memory, but java cannot directly operate it. ;

2. C language can encapsulate dynamic libraries, but java cannot;

3. C language code is not easy to cross-platform, while java code is easy to cross-platform;

4 , C language has pointers, java does not have pointers;

5. C language can directly operate the serial port, java needs third-party jar package support;

6. C language threads are more flexible, java's Threads have been encapsulated;

7. C language can be used as a separate function, which can increase efficiency, and java is suitable for web application development;

8. The identifiers available in C language are numbers and sizes. Write letters, underscores, and cannot start with a number; in addition to the three types of identifiers available in C, Java has one more dollar sign ($), which also cannot start with a number.

9. Logical operators and bitwise operators

The logical operators &&, ||, ! both in C and Java. There are three types, and they have the same meaning. The difference is that the operation result in C is 0 and non-0, while in Java it can only be true or false. There are also &, |, ^ (XOR) in Java. The difference between & and &&, | and || is that the former is a non-shortcut operator and the latter is a shortcut operator, that is, judgments are made before and after &, and if false before &&, no judgment is made. For the subsequent judgment, |judges both before and after. If || is true before, the subsequent judgment will not be made. ^ means both are the same and false.

The bitwise operators in both C and Java are: &, |, ^, ~ (inversion), << (left shift), >> (right shift), their meanings are basic same. The right shift operation of negative numbers in C differs depending on the system (it may be an arithmetic right shift or a logical right shift), while in Java, >> represents an arithmetic right shift, that is, the highest bit is filled with the sign bit. The logical right shift (unsigned right shift) operator in Java is >>>, which uses two's complement right shift and adds 0 to the high bit.

10. Keywords:

The keywords in C are:

auto break case char const

continue default do double else

enum extern float for goto

if int long register return

short signed sizeof static struct

switch typedef union unsigned void

volatile while

The keywords in Java are:

abstract boolean break byte case

catch char class continue default

do double else extends false

final finally float for if

implements import instanceof int interface

long native new null package

private protected public return short

this throw throws transient true

try static super switch synchronized

void volatile while

11. Different basic data types:

The c language is int short long char float double and there are some special types of structures, pointers, unions, etc., arrays, strings;

java is byte int short long float double char boolean, and the basics of c language The number of digits in the type is related to the operating system and machine, but Java is fixed;

12. The file organization method is different

C language will put the declaration of global variables and methods in one Inside the file, it is called a header file, and Java organizes files by classes;

Recommended learning: Java video tutorial

The above is the detailed content of Is there any difference between c syntax and java syntax?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template