//using break within a loop
// eliminating the letter c
String puppy = "DipStick";
int count = -1;
while (count < 7)
{
count++;
if (puppy.charAt(count)=='c')
break;
System.out.println(puppy.charAt(count));
}
System.out.println("Isn't this puppy a cutie!!"); |
//using continue within a loop
// eliminating the letter c
String puppy="DipStick";
int count = -1;
while (count < 7)
{
count++;
if (
puppy.charAt(count) =='c')
continue;
System.out.println(puppy.charAt(count));
}
System.out.println("Isn't this puppy a cutie!!"); |