Hands-on brain to learn Java

Source: Internet
Author: User

Enumtest:

1. The enumeration type is a reference type.

  2. system.out.println (S.getclass (). isprimitive ()); false size s=size.small;     Size t=Size.LARGE; System.out.println (s==t) false ). The same value refers to the same object ( size u=size.valueof ("SMALL"); System.out.println (s==u); ).

3. You can use the "= =" and the equals () methods to directly compare the values of the enumeration variables, in other words, for variables of the enumeration type,"= =" and The result of the equals () method execution is equivalent.

Hands on Brain 2:

the output is: x+y=100200

300=x+y

System.out.println ("x+y=" +x+y); the meaning is to y Variables and x the value of the variable is printed as a string, so the result is x+y=100200

and System.out.println (x+y+ "=x+y"); is calculated first X+y value is then set to the value of the "=x+y" print them together as characters.

After-school exercises:

Binary representation of the number:

The original code: is the binary fixed-point notation, that is, the highest bit is the sign bit, "0" indicates positive, "1" represents a negative, and the remaining bits represent the size of the value.

Anti-code: The inverse code of positive number is the same as its original code, negative number of the inverse code is to its original code bitwise negation, except the sign bit.

Complement : The complement of a positive number is the same as its original code, the complement of negative is in its inverse code of the bottom plus 1 .

Scope of the variable:

The value of the output should be from the values of the nearest value of System.out.print (value) and will be written in public static void main (string[] args) {}.

Hands-on brain to learn Java

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.