Ok, I'm ripping my hair out over this.
I have a huge 50,000 line tsv file that I am reading through (cannot provide file for copyright reasons). I am looking for only the relevant data for the restrictions provided.
In this snippet of code:
I am reading through the lines. The first two tokens are the Year and then the Month for the proceding tokens data.boolean start = false; while(line!=null) { StringTokenizer tokenizer = new StringTokenizer(line); int year = Integer.parseInt(tokenizer.nextToken()); int month = Integer.parseInt(tokenizer.nextToken()); //System.out.println("sy: "+sy+" sm: "+sm+"\n Year: "+year+" Month: "+month); if(!start && sy.equals(year+"") && sm.equals(month+"")) { start = true; System.out.println("Found Start YEAR: "+year+" MONTH: "+month); System.out.println(months[month-1]); } if(month==3) { System.out.println("March Found: "+months[month-1]); } if(months[month-1].equalsIgnoreCase(cutMonth)) break; if(start) {
Now, for this example, I have varified that cutMonth is equal to "Mar". And I have varified that it runs into times when it finds Mar for the line Month.
So, when the Month is March, month will equal 3. When month equals 3, months[month-1] equals "Mar".
So, how is it possible for something to enter this if statement:
But not this if statement:if(month==3) { System.out.println("March Found: "+months[month-1]); }
if(months[month-1].equalsIgnoreCase(cutMonth)) break;
If it enters the second if statement, it should break out of the while loop, correct?
Tell me if I need to explain something in more detail. Any help is appreciated.