Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2468

Re: For loop on Word List

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.help
Subject Re: For loop on Word List
Date Wed, 23 Jan 2013 11:30:54 -0500
Organization A noiseless patient Spider
Lines 31
Message-ID <kdp37v$5ms$1@dont-email.me> (permalink)
References <43165a8a-3a3b-4869-aa7e-3c4e4bbc5898@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 23 Jan 2013 16:30:55 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="5852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pHA7Q708bnmYxEaYmESIy"
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
In-Reply-To <43165a8a-3a3b-4869-aa7e-3c4e4bbc5898@googlegroups.com>
Cancel-Lock sha1:y92yf91rHQ24b5wKHfnASZKfoX0=
Xref csiph.com comp.lang.java.help:2468

Show key headers only | View raw


On 1/23/2013 11:01 AM, subhabangalore@gmail.com wrote:
> Dear Group,
>
> I am trying to learn Java.
>
> If I have a string like,
> "Moscow is the capital of Russia",
> I like to see it as,
>
> ["Moscow","is","the","capital","of","Russia"]
>
> "Moscow",0
> "is",1
> "the",2
> "capital",3
> "of",4
> "Russia",5
>
> the string into a bag of words, and each word and its corresponding index.
>
> If any one can help me.

     Since this sounds very much like homework, I won't offer
a fully worked-out solution.  Instead, I'll suggest that you
look at the split() method of the String class (there are two
split() methods, but I think the one-argument version is better
for the purpose you describe).

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

For loop on Word List subhabangalore@gmail.com - 2013-01-23 08:01 -0800
  Re: For loop on Word List Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-23 11:30 -0500
  Re: For loop on Word List subhabangalore@gmail.com - 2013-01-23 09:26 -0800
    Re: For loop on Word List markspace <markspace@nospam.nospam> - 2013-01-23 17:33 -0800
  Re: For loop on Word List Roedy Green <see_website@mindprod.com.invalid> - 2013-01-23 19:40 -0800

csiph-web