Some of the things that are easy to get wrong in Java writing

Source: Internet
Author: User
1) instanceof: An object of a class that implements an interface is also an instance of that interface, and an object of a class is also an instance of that class superclass.

2 The method of native () is not a method body, with a semicolon ";" instead of curly braces.

3 main is not a keyword.

4) system.exit (int value), that is, as long as it is int, it can cause the JVM to exit System.exit (' a ');

5) &,| can be used on int and Boolean, while ^ (XOR) can only be used on int.

6 If a class and an interface are defined in the same file, and the class is declared public, then nothing can be written before the interface because the interface can only be decorated with public, and only one file can have a public access control keyword.

7) Unreachable statement A few of the following situations will appear unreachable statement

(1) Write the statement after the REUTRN statement.
(2) Write the statement after the throw statement.
(3) Define the statement after the break, continue statement.

8 "\u10100"//legal, equivalent to ' \u1010 ' and string ' 0 '

9 The shift operator can be used for long int char short byte

10 the access control character of the class can be public or nothing.

Goto is a reserved word but not a keyword. then is nothing.

12 when the type of the superclass is cast to the object of the subclass, no exception is compiled, but there is an exception at run time.





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.