break and continue


break is used for exit from the loop based on some condition.

break can be used with labeled and unlabeled.


public class BreakLearn {
    private static final String[] ARR = {"India","Pakistan", "Austrelia", "Srilanka", 
            "South Africa"};
    public static void main(String arg[]){
        for(int i = 0; i <= ARR.length; i++){
                System.out.println("Entered into if condition");
                break Search;


Continue is used for stop the current execution and start the execution from the start of the loop or from the label specified .


private static final String[] ARR = { "India", "Pakistan", "Austrelia", "Srilanka", "South Africa" };

    public static void main(String arg[]) {
//        Search: 
            for (int i = 0; i < ARR.length; i++) {
            if ("Austrelia".equals(ARR[i])) {
                System.out.println("Entered into if condition");



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s