String to Char array conversion: Yes, we can do it. It is dead simple. It is just possible with a simple method String class' toCharArray() which converts string to char array easily. It converts that string to char array on which the toCharArray() method is called.
st.toCharArray(): This method as is called on the string object st which is pre-stored in the class string when the object was created, converts that object into character array.
The internal coding for this method may be splitting the given string with "" that is it, if split() method has come before this method has. Whatever, you can also work the same with the split() method in the String class by passing the "" to split() method.
Here is an example of split method, you can refer it here.
-----------------------------------
Output
-----------------------------------
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
st.toCharArray(): This method as is called on the string object st which is pre-stored in the class string when the object was created, converts that object into character array.
The internal coding for this method may be splitting the given string with "" that is it, if split() method has come before this method has. Whatever, you can also work the same with the split() method in the String class by passing the "" to split() method.
Here is an example of split method, you can refer it here.
-----------------------------------
Output
-----------------------------------
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
No comments:
Post a Comment