package test;
public class Loop_Statement {
public static void main(String [] args)
{
String[] newbag = new String[] {"Bag","Key","Book"};
//The usage of break
int j = 0;
while (j<newbag.length)
{
if(newbag[j] == "Key")
{
System.out.println("I have find the key!");
break;
//continue;
}
else
{
System.out.println("This is : "+newbag[j]+" , not key !");
}
j++;
}
//The usage of continue
j = 0;
while (j<newbag.length)
{
if (newbag[j]!="Book")
{
j++;
continue;
}
System.out.println("I have find: "+newbag[j]);
j++;
}
}
}