python convert char array to string code example
Example 1: Convert char array to string in java
public class CharArrayToString
{
public static void main(String[] args)
{
char[] charArray = new char[]{'F','l','o','w','e','r','B','r','a','c','k','e','t','s'};
String str = new String(charArray);
System.out.println(str);
}
}
Example 2: how to join a list of characters in python
>>> a = ['a', 'b', 'c', 'd']
>>> ''.join(a)
'abcd'
Example 3: char array to string
String string = String.valueOf(a);
Example 4: converting char array to string
class Util
{
public static void main(String[] args)
{
char[] chars = {'T', 'e', 'c', 'h', 'i', 'e', ' ',
'D', 'e', 'l', 'i', 'g', 'h', 't'};
String string = new String(chars);
System.out.println(string);
}
}
Example 5: how to save string characters into char array or list in python
fd = open(filename, 'rU')
chars = []
for line in fd:
chars.extend(line)