java - Comparing a string to a part of string inside an arraylist -


The title may be a little confusing or misleading, but I'm trying to compare a string:

string mestring = "ABC";

and then try to compare it with every single string contained in the array list

  ArrayList & lt; String & gt; Array = new arreelist & lt; String & gt; (); Array.add ("The first letters of the alphabet are ABC"); Array.add ("abc"); Array.add ("alphabet"); Array.add ("nothing"); But (and I'm not sure) it seems that this is true only if both the strings do not match and not the word or phrase is inside the string.  

How do I add a desired string to a "phrase" which is inside ArrayList strings?

To check if you're asking, you must be repeated through the values ​​array included in, and check whether they value the string you want to select

  (for string Searere: array) {ifArray.contains (mystring)) {// put your code here}}  

This method is case sensitive to overcome it, you can either convert strings to lowercase(With toLowerCase () method), or use a library that is designed to do this. One such library is Apache Commons Library.

>

/ div>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -