The linguistic basis of similarities and differences between Java and C + +

Source: Internet
Author: User

1. Package Declaration

A Java application is made up of several classes, and the file name must have the same name as the class name. Package is a keyword for packages that declares the package in which the class resides.

2. Basic data types

For long values, if the assigned value is greater than or less than the int value range, you need to add L or L after the number to indicate that the number is a long integer.

By default, decimals are treated as double type, and if you use float decimal, you need to add F or F after the decimal.

Boolean type uses Boolean.

3. Identifiers

Identifiers consist of any sequence of parents, underscores (_), Dollar signs ($), and numbers, and the first character is not a number.

4. Constants

Use the final keyword.

5. Shift operation

>> right shift the highest bit is 0, the right to move the empty bit is filled in 0, the highest bit is 1, the right to move the empty bit is filled in 1

>>> unsigned Right Shift right move empty bit just fill in 0

Test:

Package Test1;public class TestClass {public static void main (string[] args) {//Boolboolean B = false; System.out.println (b);//constant final float $fData = 10.2f; System.out.println ($fData);//The displacement operation int J = 4;//The highest bit is 0, the right to move the empty bit is filled in 0, the highest bit is 1, the right to move the empty bit is filled in 1system.out.println (J >> 2); 0system.out.println (J >>> 2) is filled in with the right-hand-shifted space;}


The linguistic basis of similarities and differences between Java and C + +

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.