Let me start by listing the current construction methods used by beginners
How to construct a String:
String () Creates an empty content string object.
String (byte[] bytes) Constructs a string object using a single byte array
String (byte[] bytes, int offset, int length)
Bytes: The array to decode
Offset: Specifies that the decoding is started from that index value in the array.
Length: to decode multiple elements.
String (char[] value) constructs a string using a character array.
String (char[] value, int offset, int count) uses a character array to construct a string, specifying the starting index value, and the number of characters to use.
String (int[] codepoints,int offset,int count)
String (string original)
public class Demo2 {public static void main (string[] args) {string str = new string ();//Create an empty Content string Object constructor: string () by Te[] Buf = {97,98,99};str = new String (BUF); Constructs a string object constructor using a single byte array : String (byte[] bytes) str = new string (buf,1,2); Constructs a string object using a byte array that specifies the number of index values and decoding to start decoding. The constructors used are: String (byte[] bytes, int offset, int length) char[] arr = {' Ming ', ' Day ', ' yes ', ' holy ', ' Christmas '};str = new String (arr); Use a character array to build a string ( char[] value) str = new string (arr,3,2);//Use String (char[] value, int offset, int count) Constructor int[] Buf2 = {65,66,67};str = new string (buf2,0,3),//Use String (int[] Codepoints,int offset,int count) constructor str = new S Tring ("abc");//Use the string (string original) constructor System.out.println ("contents of the string:" +str);}}
AC Penguin: 654249738, and self-taught Exchange group: 517284938
Construction method of Java_se base--62.string class