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


Groups > comp.lang.java.programmer > #21709

Re: Index of List

From "John B. Matthews" <nospam@nospam.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Index of List
Date 2013-01-25 12:48 -0500
Organization The Wasteland
Message-ID <nospam-02736B.12483425012013@news.aioe.org> (permalink)
References <8fb20d2d-260b-42a1-9899-d038d2abfa5e@gg5g2000pbc.googlegroups.com>

Show all headers | View raw


In article 
<8fb20d2d-260b-42a1-9899-d038d2abfa5e@gg5g2000pbc.googlegroups.co
m>,
 Subhabrata <subhabangalore@gmail.com> wrote:

>I am a new programmer in Java.
>
> I want to have check whether one word from one list is there 
> in another list and if it is there I like to extract its next 
> word.
> 
> For example, If I have a string like,
> 
> "Moscow is the capital of Russia"
> 
> The wordlist would be "Moscow", "is","the","capital","of","Russia"
> 
> Now suppose I have a string of words like,
> 
> "Moscow", "Leningrad", "is", "was", "the", "a", "capital", 
> "state", "of", "by", "Russia", "Romania"
> 
> Here as one word is identified from the first string in the 
> second string the cursor points to the next word, rather it 
> exploits hashing.
> 
> I know:
> (i) Declaring String.
> (ii)Using String.split
> (iii) I can use the for loop over the string and find out indexing.
> (iv) I know .equals
> 
> But I think I am missing something like if Java has .find or .index
> sort of thing then it would be very easy to do.
> 
> Does Java have anything?

Implementations of the java.util.List interface have a 
convenient contains() method, Collections.binarySearch() may be 
warranted for searching sufficiently long lists.

Implementations of the java.util.Map interface map keys to 
values, often using hashing.

As you are new to Java, it might be worth starting here:

<http://docs.oracle.com/javase/tutorial/collections/index.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

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


Thread

Index of List Subhabrata <subhabangalore@gmail.com> - 2013-01-25 09:07 -0800
  Re: Index of List Tim Slattery <Slattery_T@bls.gov> - 2013-01-25 12:38 -0500
  Re: Index of List "John B. Matthews" <nospam@nospam.invalid> - 2013-01-25 12:48 -0500
  Re: Index of List Arne Vajhøj <arne@vajhoej.dk> - 2013-01-25 21:44 -0500
  Re: Index of List Roedy Green <see_website@mindprod.com.invalid> - 2013-01-26 19:22 -0800

csiph-web