473,473 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Removing spaces from an ArrayList

2 New Member
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
2 13545
Mr Smiggins
2 New Member
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
r035198x
13,262 MVP
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

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

Similar topics

9
by: hokiegal99 | last post by:
This script works as I expect, except for the last section. I want the last section to actually remove all spaces from the front and/or end of filenames. For example, a file that was named " test ...
5
by: tgiles | last post by:
Hi, all. I'm YAPN (Yet Another Python Newbie), started messing with it last night and so far, so good. Documentation exellent and the people seem friendly enough ;) Ok, I started playing...
1
by: Billy Cormic | last post by:
Hello, This is a simple question, hopefully with a simple answer. I have an nvarchar column of length 255. In one of the rows I have the following sentance - 'See the brown ball bounce'. Is it...
12
by: Magix | last post by:
Hi, Everytime I received a fix-length of string, let say 15 (the unused portion will filled with Spaces before receive), I want to remove the Spaces from END until I encounter a non-space char....
1
by: Mike in Paradise | last post by:
Is there a more effcient way of removing the spaces from the names for a Enumerated value that has several values when you split it)??? When you do a toString it puts ,<SPACE> between the entries...
3
by: lino | last post by:
Hello, I have the following string: const char plaintext = "Fourscore and seven years ago our \ fathers brought forth upon this continent \ a new nation, conceived in liberty, and dedicated...
2
by: warthogweb | last post by:
This is in relation to BANFA's succinct reply to my post the other day. I have a bunch of phone numbers that contain one or two spaces and that I want to get consistent by removing them. However,...
8
by: starsky51 | last post by:
I'm sure it's something i'm doing wrong, I just can't see it. I've set up a simple page with the following code: <html> <head> <title>tester</title> <script language="javascript"...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.