Q:

how can i block a particular url from a string array

i have four url of different extension, i just want block a particular urls depending upon .extension.
how could i do that?
 i have use  if condition, but if does not give me my desire out put
i have done this code
String line[]={"https://google.com","https://www.facebook.swf","http://www.hotstar.com","http://www.deathbycaptcha.com/user/login.js"};

for( int i=0;i<=line.length;i++){ 
    String ln=line[i];

    if(ln.endsWith(".css")){
        break;
    }
    if(ln.endsWith(".js")){

    } 
    if(ln.endsWith(".jpg")){
        break;
    }

    if(ln.endsWith(".fla")){
        break;
    }
    if(ln.endsWith(".swf")){
        break 
    }
    else{
        System.out.println("urls :"+ln);
    } 
}

how could i do this
if it will be in switch case or other  then please  help me.
thanks in advance.

A:

You are using a break that stop the loop, if you want to check the full loop but skip a specific one with this logic, you need to use continue. 
Break will stop the loop where it was, without any check.
Continue will stop the statement block of the loop and will check the condition of the loop again, this will not exit the loop.
I took the liberty to regroup the tests into one if-clause.
for( int i=0;i<=line.length;i++)
{ 
    String ln=line[i];
    if(ln.endsWith(".css")
              || ln.endsWith(".fla") 
              || ln.endsWith(".swf") 
              || ln.endsWith(".jpg"))){
        continue;
    } else {
        System.out.println("urls :"+ln);
    } 
}

But you could simply reverse the condition to print if this is not like .css or fla ... without an else clause

