Get the App
SLTechnology News&Howtos  ›  Database  › 

The Construction method and General method of String

Shulou Source: shulou.com Published: 2022-06-01 04:44:31 09月25日 Update

Public class StringTest {public static void main (String [] args) {/ / 1 String S1 = "abc"; / / 2 String S2 = new String ("cdg"); / / 3 byte [] bytes= {98 new String (bytes); String S3 = new String (bytes); / / 4String (byte [] bytes, int offset, int length) Constructs a new String by decoding the specified subarray of bytes using the platform's default charse String S4 = new String (bytes,1,3); / / 5. Char [] C1 = {'I', 'Shi', 'Zhong', 'Guo', 'Ren'}; String S5 = new String (C1); System.out.println (S5); / / I am Chinese / / 6. String S6 = new String (c1jue 2); System.out.println (S6) / / China System.out.println (S3); / / abcd String has rewritten toString}} / * common string methods in Object * / public class StringTest06 {public static void main (String [] args) {/ / 1.char charAt (int index); String S1 = "I am Wang Yong, the bad guy!" ; char C1 = s1.charAt (2); System.out.println (C1); / / Wang / / 2.boolean endsWith (String endStr); System.out.println ("HelloWorld.java" .endsWith ("java")); / / true System.out.println ("HelloWorld.java" .endsWith (".java")) / / true System.out.println ("HelloWorld.java" .endsWith ("HelloWorld.java")); / / true System.out.println ("HelloWorld.java" .endsWith ("txt")); / / false System.out.println ("HelloWorld.java" .endsWith ("java")) / / false / / 3. Boolean equalsIgnoreCase (String anotherString); System.out.println ("abc" .equals IgnoreCase ("ABc")); / / true / / 4.byte [] getBytes (); byte [] bytes = "abc" .getBytes (); for (int iSignoreCase)

Tags: Methods characters strings arrays Chinese Chinese bad guys uppercase lowercase attributes commonly used pointers programs spaces Li Hai Li Haibo Wang Yong processing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information Redmi Xiaomi NVidia