Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2469
| X-Received | by 10.66.72.227 with SMTP id g3mr205726pav.31.1358962001552; Wed, 23 Jan 2013 09:26:41 -0800 (PST) |
|---|---|
| X-Received | by 10.50.191.131 with SMTP id gy3mr736477igc.1.1358962001513; Wed, 23 Jan 2013 09:26:41 -0800 (PST) |
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!f6no11772417pbd.1!news-out.google.com!s9ni12616pbb.0!nntp.google.com!f6no11772411pbd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.help |
| Date | Wed, 23 Jan 2013 09:26:41 -0800 (PST) |
| In-Reply-To | <43165a8a-3a3b-4869-aa7e-3c4e4bbc5898@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=122.161.165.164; posting-account=6SonuQoAAACzSakS5dCECcJQe6ylLrzY |
| NNTP-Posting-Host | 122.161.165.164 |
| References | <43165a8a-3a3b-4869-aa7e-3c4e4bbc5898@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <e7e6d308-c7aa-4fc6-a92e-0d6dff7d2884@googlegroups.com> (permalink) |
| Subject | Re: For loop on Word List |
| From | subhabangalore@gmail.com |
| Injection-Date | Wed, 23 Jan 2013 17:26:41 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.java.help:2469 |
Show key headers only | View raw
On Wednesday, January 23, 2013 9:31:30 PM UTC+5:30, subhaba...@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.
>
>
>
> Regards,
>
> Subhabrata.
Dear Sir,
Thank you for the help. I worked out the following solution.
It seems working.
public class For_loop {
public static void main(String args[]) {
String mystring="Subhabrata Banerjee works in India";
String[]word=mystring.split(" ");
int l2=word.length;
int l1=mystring.length();
for(int x = 0; x < l2; x = x+1) {
System.out.print("value of x : " + x );
System.out.println(word[x]);
System.out.print("\n");
}
}
}
Regards,
Subhabrata.
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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