By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,782 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,782 IT Pros & Developers. It's quick & easy.

Removing spaces from an ArrayList

P: 2
I'm trying to make a method that removes all cells that are just spaces from an ArrayList. So far I have this:

Expand|Select|Wrap|Line Numbers
  1. public ArrayList removeSpace()
  2.     {
  3.         Iterator<String> it = array.iterator();
  4.             while (it.hasNext())
  5.             {
  6.                 if (it.next().equals(" "))
  7.                 {
  8.                     it.remove();
  9.                 }
  10.             }
  11.         return array;
This unfortunately seems to return a completely empty ArrayList. Any ideas?
Thanks in advance
Jan 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
Well I'm certainly an idiot. It actually worked fine. Always a good idea not to start off with an empty array if you don't want to end up with one.
Jan 4 '07 #2

10K+
P: 13,264
Well I'm certainly an idiot. It actually worked fine. Always a good idea not to start off with an empty array if you don't want to end up with one.
A very good idea indeed. Good to know that you found the problem yourself.


Good luck with the rest of it.
Jan 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.