Scala String toCharArray() method with example
Last Updated :
29 Oct, 2019
The toCharArray() method is utilized to convert a stated string to CharArray.
Method Definition: char[] toCharArray()
Return Type: It returns CharArray.
Example: 1#
object GfG
{
def main(args : Array[String])
{
val result = "GeeksforGeeks" .toCharArray()
for (m 1 < -result)
{
println(m 1 )
}
}
}
|
Output:
G
e
e
k
s
f
o
r
G
e
e
k
s
Example: 2#
object GfG
{
def main(args : Array[String])
{
val result = "Nidhi" .toCharArray()
for (m 1 < - result)
{
println(m 1 )
}
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...