09 April 2012

Display all elements of an array from 1-10 except 5 (use continue).




import java.util.*;
public class Continue {
public static void main(String[] args) {
int intArray[]={0,1,2,3,4,5,6,7,8,9};
Scanner input = new Scanner(System.in);
System.out.println("Array elements are");
for(int i=0; i<intArray.length; i++)
{
System.out.print(intArray[i]+" ");
}
System.out.println("Type the Number you want to skip");
int n = input.nextInt();
for(int i=0; i<intArray.length; i++)
{
if(n==i)
continue;
System.out.print(i+" ");
}
}

}

/*
Array elements are
0 1 2 3 4 5 6 7 8 9 Type the Number you want to skip
5
0 1 2 3 4 6 7 8 9
*/

1 comments:

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;