Java entry and FAQ

xiaoxiao2021-03-06  55

4 StringBuffer S1 = New StringBuffer ("a"); StringBuffer S2 = New StringBuffer ("a"); S1.Equals (S2) // Why is FalseString S1 = New String ("a"); string s2 = new string "a"); s1.equals (s2) // Why is TRUE is actually very simple, I will summarize it. First, String's Equals method is to override Object, so string a = new string ("ss"); string b = new string ("ss"); generated two objects, but a.equals (b) = true, Compare the value. Second, StringBuffer's equals method does not override the object of Object, so StringBuffer a = new stringbuffer ("ss"); StringBuffer B = New StringBuffer ("ss"); "SS"); , Compare the address. Third, the equal sign is the address, string a = "a"; string b = a; only one object A == B true. StringBuffer A = New StringBuffer ("a"); stringbuffer b = a; also generates an object a == b true. Fourth, string a = "ss"; string b = "s"; a.equals (b) = true a == b true because it is also an object. This is because only one object "SS" is generated when compiling. String a = new string ("ss"); string b = new string ("ss"); a.equals (b) = true, no doubt, a == b false. Because A, B is an object that is generated at runtime, two objects have been generated. Important: Compile objects and run objects. 5. What is Java Web Start? look here

Http://java.sun.com/products/javawe...adme_zh_cn.html

转载请注明原文地址:https://www.9cbs.com/read-109460.html

New Post(0)