Java hands-on brain

Source: Internet
Author: User

1. Read the example carefully: Enumtest.java, run it, analyze the running results? What conclusions can you get? Have you mastered the basic usage of enum types?

public class Enumtest {public    static void Main (string[] args) {        Size s=size.small;        Size T=size.large;        S and T refer to the same object?        System.out.println (s==t);        //is the original data type?        System.out.println (S.getclass (). isprimitive ());//Determine whether the data for the class package is        converted from string to        Size u=size.valueof ("SMALL") ;        System.out.println (s==u);  True        //lists all its values for        (Size value:Size.values ()) {            System.out.println (value);}        }    }

The first one determines if s and T refer to the same object, the second determines whether it is a class-wrapped data, the third T determines whether s is equal to u, lists all the elements inside it, so the enumeration type is a reference type, the enumeration is not of the original data type, and each of its specific values refers to a specific object that can be used The value of the directly-compared enumeration variable.

2. Read the corresponding textbook, or use the Internet search engine to find out the concepts of anti-code, complement and original code

The original code is the absolute value of the symbol bit plus the truth, that is, the first digit to represent the symbol, the remaining bits represent the values,

The complement of the expression method is: a positive complement is its own negative complement is in its original code on the basis of the symbol bit unchanged, the rest of you take the counter, the last +1. (That is, on the basis of the anti-code +1)

The inverse code is represented by: the inverse of a positive number is its own negative anti-code is in its original code based on the symbol bit unchanged, the remaining bits are reversed.

3.Java variables follow the "shielding principle of variable with the same name", please read the relevant information after class to clarify the relevant knowledge.

In the code, the first value is a member variable, is also a global variable, the second value is a local variable, the local variable can overwrite the global variable, when the local use of a variable, the JVM will first find and the current position near the definition of the variable.

Java hands-on brain

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.