Q:

Write a Java program to rotate an array (length 3) of integers in left direction

0

Write a Java program to rotate an array (length 3) of integers in left direction

Sample Output:

Original Array: [20, 30, 40]                                           
Rotated Array: [30, 40, 20]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Arrays; 
 public class Exercise79 {
 public static void main(String[] args)
 {
    int[] array_nums = {20, 30, 40};
	System.out.println("Original Array: "+Arrays.toString(array_nums)); 
	int[] new_array_nums = {array_nums[1], array_nums[2], array_nums[0]};
	System.out.println("Rotated Array: "+Arrays.toString(new_array_nums)); 	 
 }
}

Sample Output:

Original Array: [20, 30, 40]                                           
Rotated Array: [30, 40, 20] 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now