Write a Java program to convert all characters in a string to lowercase

Write a Java program to cyclically rotate a given array clockwise by one

Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.Arrays;
 public class Javaexcercise
{
    static int arra[] = new int[]{1, 2, 3, 4, 5, 6, 7, 8};
 
    static void rotate_array()
    {
       int num = arra[arra.length-1], i;
       for (i = arra.length-1; i > 0; i--)
          arra[i] = arra[i-1];
       arra[0] = num;
    }
 
   public static void main(String[] args) 
    {
        System.out.println("Original arraay:");
        System.out.println(Arrays.toString(arra));
 
        rotate_array();
 
        System.out.println("Rotated arraay:");
        System.out.println(Arrays.toString(arra));
    }
}

Result

Write a Java program to cyclically rotate a given array clockwise by one
Write a Java program to cyclically rotate a given array clockwise by one

Add a Comment

Your email address will not be published. Required fields are marked *