Below we introduce common methods of common classes and classes provided by Java class Library
First, java.lang.String
1. Constructors common to the string class
Public String(string original)
Create a String object using the String object original, where original can be a string constant or a string object
Public String (char value[])
Create a String object using the character array value
Public String (char value[],int offset,int count)
Creates a string object with count characters starting with the character array value subscript as offset
Public String (stringbuffer buffer)
Create a String object using the object buffer of the StringBuffer class
Our upper and lower code:
1 Packagecom.learn.chap04.sec05;2 3 Public classString1 {4 Public Static voidMain (string[] args) {5String S1 =new String ("ASCD");6String s2 =new String (S1);7 8 Char[] Value =New Char[]{' A ', ' B ', ' C '};9String s3 =new String (value); //copy entire arrayTenString S4 =new String (value,1,2); //Create the string "BC" One System.out.println (S1); A System.out.println (S2); - System.out.println (S3); - System.out.println (S4); the } -}
Operation Result:
Ascd
Ascd
Abc
Bc
Common classes and methods of Java