String a=new String ("a");
String b=new String ("a");
// This is the comparison address
System.out.println(a==b);//false
// This is a comparative value
System.out.println(a.equals(b));//true

//new The way you put it in the pile , Different addresses

String c="a";
String d="a";
// This is the comparison address
System.out.println(c==d);//true
// This is a comparative value
System.out.println(c.equals(d));//true

// no need new The way to do this is to put it in the constant pool

// One in the constant pool , One is in the heap , So the address is different

System.out.println(c==a);//false
System.out.println(c.equals(a));//true

new String(“a”) And String a="a"; More articles about

  1. use java String Class getBytes(String charsetName) and String(byte[] bytes, String charsetName) Solve the mess

    Java in String How is the data stored , Look at the source code to see ,String The data is stored in char[] value In such a member variable ,char The size of the type is in java Medium is 2 Bytes   We also know that , Now it is common to make ...

  2. string.IsNullOrEmpty and string.IsNullOrWhiteSpace Differences in methods

    string.IsNullOrEmpty We all know , This function is to determine whether the string is :null perhaps string.Empty. If yes "\t" Such a character returns false 了 , In order to achieve judgment filtering, this ...

  3. About String str =new String("abc") and String str = "abc" Comparison

    String Is a very common class , We should have a deep understanding of String Such as : String str =new String("abc") String str1 = "abc&qu ...

  4. Javascript in String() And new String() The difference of

    The main focus here is on value types and reference types . We know that javascript There are two ways to store variables in memory , Value type storage and reference type storage . The common ways to store values include   String type , Boolean type , Numeric type , They all contain ...

  5. C#、.Net Code reduction and optimization ( Empty operators (??)、as、string.IsNullOrEmpty() 、 string.IsNullOrWhiteSpace()、string.Equals()、System.IO.Path Usage of )

    One . Empty operators (??) In the program, we often encounter the judgment of string or object null The operation of , If null Then give a null value or a specified value . Usually we deal with it like this : .string name = value; if (name ...

  6. classic String str = new String("abc") Memory allocation problem

    come from :http://blog.csdn.net/ycwload/article/details/2650059 Today I'm looking for some knowledge about storage management , I searched the Internet for a long time, but I didn't find a perfect one (30% Not to the extent that ), no ...

  7. Several modes and efficiency of judging the existence of string (string.contains、string.IndexOf、Regex.Match)

    Usually , We often use... To determine whether a value exists in a string string.contains, In fact, there are many ways to determine the existence of a value in a string , The most commonly used one is the one mentioned above string.contains, Relatively speaking, the more commonly used ...

  8. C# string.format、string.connect and += operation Efficiency calculation

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Stri ...

  9. How to integrate List<string> Turn into string

    Convert List, string. A List can be converted to a string. This is possible with the ToArray method ...

  10. 1, Whether the character is empty ,2, Compare the size of two characters .String.Compare(String, String).string.IsNullOrEmpty(string)

    1, String.Compare Method (String, String) Compare two specified  String  object . value Conditions Less than zero strA  Less than  strB. zero strA  be equal to  strB. Greater than zero ...

Random recommendation

  1. spoj 371 Boxes

    N A box in a circle , The first i The first box had Ai A little ball , You can move a ball from one box to one of the two adjacent boxes at a time . How many times should I move at least so that the number of balls in each box does not exceed 1. ΣAi<=N.1<=N<=1 ...

  2. SharePoint Automation series ——Add content type to list.

    Please indicate that it is from tianwaiguiyun's blog park :http://www.cnblogs.com/LanTianYou/ Will create the content type( If cross web application It needs to be done in advance publish c ...

  3. case in esac ` for in do done ` while true / false

    case  in esac  `  for in do done   `   while true / false ` if {} fi

  4. SGU 310. Hippopotamus( Pressure dp )

    The main idea of the topic : to N Block plate , Yes A,B2 Two types of boards , Ask for anything M There are at least K block B plate .1≤n≤60,1≤m≤15,0≤k≤m≤n. dp(x, s) It means the first one x Block plate , x front M The state of the block is s, And then it's legal ...

  5. ( Two )Python What kind of language is it ?

    I'm learning python Before you know what kind of language it is, you need to know what compilation and interpretation are ? Compiler is to compile every statement of source program into machine language , And save as binary file , In this way, the runtime computer can run the program directly in machine language , fast ; and ...

  6. Visual Studio 2012 Development environment configuration + Console tools + Desktop applications

    One . Interface layout view settings 1. The layout of the window . The setting method of the console window running back to the development environment You can also save your personalized settings , Import settings : 2. View | Server Explorer (sever explorer) Access to data sources . service ...

  7. win8 Use putty Log in to the virtual machine linux

    I've been trying since two in the afternoon , It's almost used 6 I've been successful since I was an hour ! The connector uses putty, Just know the virtual machine's ip Address can try to connect , So first query the ip Address , Use command : ifconfig Prompt appears : ...

  8. Android 7.0 The storage system —Vold And MountService analysis ( One )( turn Android 9.0 analysis )

    Android Storage system ( One ) For a long time Vold Knowledge of storage modules , It's been a long time Android Source code , Find out Android Function calls involved in the storage system , as well as Kernel Between the top and Socket Transmission true ...

  9. unet

    Use unet Direct training Salient object detection data set , Can't get better effect . In some cases ( The edge pair is stronger ), The segmentation effect is OK . Due to the absence of ImageNet We get the pre training model from the model , So we can't get a good result of semantic segmentation

  10. Dart Basic key interception Dart 2 20180417

    Official website tutorial  https://www.dartlang.org/guides/language/language-tour dart It's a single thread language , No multithreading Final and const If y ...