Java Saved Program: serene-palace

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Script" only */
class Script
{
	public static void main (String[] args)
	{
	    int [] array = {1,2,3,4,5,6,7,8,9,10};
	    int temp;
	    for(int j=0; j<= 6; j++){
	        for(int i =0; i <= array.length-1; i ++){
	            if(array.length + 1 < array.length){
	                temp = array[i];
	                array[i] = array[i+1];
	                array[i+1] = temp;
	            }
	           
	        }
	    } 

	    for(int i =0; i <= array.length-1; i ++){
	        	System.out.println(array[i]);
	    }
	
		
	}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs