Some Java knowledge points

Source: Internet
Author: User

1 Importjava.util.ArrayList;2 3  Public classMain {4     5      Public Static voidMain (string[] args) {6StringBuffer buffer =NewStringBuffer ("Hello World."));7         8StringBuffer Buffer_other =buffer;9         TenBuffer.append ("Me too."); One          A         if(Buffer = =buffer_other) { -System.out.println ("OK.")); -         } the          -          -         //buffer.append (null); Error -String str =NULL; + System.out.println (Buffer.append (str)); -         //output: Hello world.me Too.null When the string is null, StringBuffer's append () converts null to a string null plus at the end +          Aarraylist<string> list =NewArraylist<>(); at List.add (str); -System.out.println (list.get (0));//output is null -List.add (NULL); -System.out.println (List.get (1));//output is null -          -         /********************************/ inString string =NULL; -String string2 =NULL; toArraylist<string> ArrayList =NULL; +         if(String = =string2) { -System.out.println ("Y");//Output y the         } *         if(String = =NULL) { $System.out.println ("Y");//Output yPanax Notoginseng         } -         if(NULL==NULL) { theSystem.out.println ("Y");//Output y +         } A         //String = = ArrayList is a syntax error the          +         //if (string.equals (string2)) {//NullPointerException -         //System.out.println ("Y"); $         //} $          -     } -}

Some Java knowledge points

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.