In Java how does one turn a String into a char or a char into a String?

前端 未结 7 1563
感情败类
感情败类 2020-12-08 01:55

Is there a way to turn a char into a String or a String with one letter into a char (like how you can turn an int

7条回答
  •  心在旅途
    2020-12-08 02:13

    In order to convert string to char

     String str = "abcd";
    char arr [] = new char[len]; // len is the length of the array
    arr = str.toCharArray();
    

提交回复
热议问题