java - comparing string to array of strings using .equals() method -


I have an array of stars (a CSV file of stock market symbols that were imported into an array list and then converted Trying to compare it to an array) But does not it seem to work, am I not comparing it to the right data type or something? Here is my code:

  import java.io.buffferedReader; Import java.io.fileReader; Import java.util.Scanner; Import java.util.StringTokenizer; Import java.util.ArrayList; Public class search {public static zero main (string [] args) {try {// csv file containing data string strings = "company list.csv"; // Create BufferedReader to read the CSV file BufferedReader br = New BufferedReader (New FileReader (strFile)); String string = ""; Stringtochnizer ST = faucet; Int line number = 0, tokonnumber = 0; // array list array list & lt; String & gt; Array list = new Array's & lt; String & gt; (); // Line line is written by comma differently than coma while ((strLine = br.readline ()) = null {lineNumber ++; // separate line from break comma "," st = new stringtochnizer (strlline, ","); While (st.hasMoreTokens ()) // // display CSV value tokenNumber ++; ArrayList.add (st.nextToken ()); //System.out.println(Line # "+ Line Number +": "+ st.nextToken () +" "+ st.nextToken ());} // Less time while // reset token number tokenNumber = 0 ;} // During the big time loop // send CSV to an array object [] element = arrayList.toArray (); / * for (int i = 0; i & lt; elements; height; i ++) { System.out.println (element [i]);} * / scanner input = new scanner (System.in); System.out.print ("Enter ticker symbol"); string sym = input.next (); For (int i = 0; i and lt; elements; langti; i ++) {if (elements [i] amails (cm) {system.out.println ("match" );}}} Hold (Exception e) {System.out.println ("Exception: During the reading of CSV file:" + E); Any help is greatly appreciated   

< First, make sure that your elements are filled properly. For example - div class = "post-text" itemprop = " Use ( trim () ) without any white space

Then you can use something simple: elementsList.contains (sym) .

Comments