集册 Java实例教程 字符串类的构造函数。

字符串类的构造函数。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

508
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
字符串类的构造函数。

public class Main 

{

   public static void main(String[] args)/*来自 N o  w  J a v a . c o m - 时  代  Java*/

   {

      char[] charArray = {'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y'};

      String s = new String("hello");


      // use String constructors

      String s1 = new String();

      String s2 = new String(s);

      String s3 = new String(charArray);

      String s4 = 
展开阅读全文