Take the 2-minute tour ×

Given an element of an ArrayList, something like:

List<String> bunchOfLetters = new ArrayList<String>(); 

and a standard method to add some letters to it, say

public void makeUpSomeLetters(){


I understand that to traverse an ArrayList to inspect elements I need to do

for(int i = 0; i<bunchOfLetters.size(); i++)

but I am clueless how to add whitespace to the end of it, e.g. making the end result become something like:

[abcdefg ] 

as opposed to just


purpose: I would like to add said whitespace so that I may take a substring for said element without having the console omit characters. thank you for your time. Cheers!

share|improve this question
Can you be more detailed please? What are the elements of your arraylist? Strings, Characters? Can you show some code how to construct it? –  Thomas Jungblut Oct 14 '12 at 8:55
add comment

1 Answer

up vote 1 down vote accepted
list.set(0, list.get(0) + " ");
System.out.print(list.get(0).equals("ABCD "));


share|improve this answer
@ Eng.Fouad that did the trick! My bad re: lack of initial specificity (pre-editing). I've since specified it. –  madrush Oct 14 '12 at 9:16
add comment

Your Answer


