Some of the details of Java attention

Source: Internet
Author: User

1. Large Bracket scope problem
 Public Static void Main (string[] args) {    {        int  x;        {            int x; // compilation error: Duplicate local variable x         }    }}
Operation of 2.boolean values
 Public Static voidMain (string[] args) {if(true&&false) {}    if(true&false) {} System.out.println (true&false); System.out.println (true^false); System.out.println (true|false);}

False
True
True

3.continue Label and Break label
 Public Static voidMain (string[] args) {label: for(inti=0; i<2; ++i) {System.out.println ("I=" +i);  for(intj=0; j<3; ++j) {            if(J = = 1){                //continue; //Break ; //continue label;                 Breaklabel; } System.out.println ("J=" +j); }    }}

In this example, continue label and break have the same effect.

 Public Static voidMain (string[] args) {label: for(intI=r; k<2; ++k) {System.out.println ("K=" +k);  for(inti=0; i<2; ++i) {System.out.println ("I=" +i);  for(intj=0; j<3; ++j) {                if(J = = 1){                    //Break ;                    Continuelabel; } System.out.println ("J=" +j); }        }    }}

This example is more intuitive to see the continue label to achieve a different effect!

4. Function overloading of parameters for basic types and corresponding objects
classa{ Public voidFunintx) {System.out.println ("Int Overload"); }         Public voidFun (Integer x) {System.out.println ("Integer Overload"); }} Public classmain{ Public Static voidMain (string[] args) {A a=NewA (); intx = 1; Integer IX= 1;         A.fun (x);    A.fun (ix); }}

int overload
Integer overload

Some of the details of Java attention

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.