de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 How do I split a string in individual chars to array?
PostPosted: Sat Feb 16, 2019 7:25 pm 
Offline
Veteran
Hello

I have simply forgotten the code to split a string into individual chars.
Can someone help me?

I want a word to be split into individual characters and added in a wordArray.
After that I will need to shuffle it, which I guess I can do with the following code:


Collections.shuffle(wordArray)


Top
 Profile Send private message 
 
 Re: How do I split a string in individual chars to array?
PostPosted: Wed Feb 20, 2019 6:34 pm 
Offline
Site Admin
User avatar
Here is a complete solution, a short and simple as possible :
Code:
def chars = Arrays.asList("the string".toCharArray())
Collections.shuffle(chars)
def s = ""
for(def c : chars)
   s += c
show(s)


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2015
This website uses session cookies only.