String Constants Demo Demo

Source: Internet
Author: User

public class Stringdemo {public static void main (string[] args) {//TODO auto-generated method stubstring str = "ABC"; String str2 = "abc";//system.out.println (STR==STR2);  True//system.out.println (Str.equals (str2)); TrueString STR3 = new String ("abc"); String STR4 = "abc";//system.out.println (STR3==STR4);  False//system.out.println (Str3.equals (STR4)); truestring STR5 = "AB" + "C"; String STR6 = "a" + "BC";//system.out.println (STR5==STR6);  True//system.out.println (Str5.equals (STR6)); truestring STR7 = "AB"; String str8 = str7+ "C"; String STR9 = "AB" + "C";//system.out.println (Str8.equals (STR9)); True//system.out.println (Str8 = = STR9); False  --str8 is a variable at run time, while STR9 is a string constant expression string str10 = "abc"; String str11 = new String ("abc"); String str12 = Str11.intern (); System.out.println (Str10 = = Str11); FalseSystem.out.println (Str10.equals (STR11)); TrueSystem.out.println (Str11.equals (str12)); True}}

String Constants Demo Demo

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.