Java : how to terminate condition check inside for loop

ateltara

New Member
I have a Array List as shown .My requirement is that , if the List consists of the value "M" in it , i want to terminate the Condition check (equals check as shown ) in the for loop , but want to continue further operations in that for loop This is my program \[code\]package com;import java.util.ArrayList;import java.util.List;public class Jai { public static void main(String args[]) { String flag = null; ArrayList<String> list = new ArrayList<String>(); list.add("M"); list.add("M"); list.add("M"); list.add("F"); list.add("M"); list.add("M"); list.add("M"); list.add("F"); for (int i = 0; i < list.size(); i++) { if (list.get(i).equals("M")) { flag = "M"; } else { flag = "F"; } // this is to indicate that i need to continue further operations // inside for loop System.out.println("Hi"); } if (flag.equals("M")) System.out.println("This is M List"); else System.out.println("This is F List"); }}\[/code\]The List is consisting of Value M in it , so i want to treat it as M List .The above program is for Simplicity , actually the List will contain Employee Objects in it .
 
Top