String s = 'a b c d e f g h i j k l m';

above code returns (, a, , b, , c, , d, , e, ...)

am I missing something? Please help

  • As per my understanding, you want to split the string by white space. But in split method you've mentioned '', which is different. Try s.split(' '). Also note that you cannot print the whole list in system.debug if the list is long enough. Try printing the list elements in for loop. – Abbas May 28 '15 at 11:44

I think its issue with logs which shows "..." after some text. Please try this:

String s = 'a b c d e f g h i j k l m';
for(String s1 : s.split(' ')){
    System.debug('value ' + s1);

Hope this will show you all values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.