Shift Character Java Program |
import java.util.Scanner;
public class Test
{
public static void main(String []args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a string to shift characters");
String test = in.nextLine();
char abc[]=test.toCharArray();
char ch=abc[0];
char chi=abc[abc.length-1];
abc[0]=chi;
for (int i=0;i<abc.length-1;i++){
chi=abc[i+1];
abc[i+1]=ch;
ch=chi;
}
String result=new String(abc);
System.out.println(result);
}
}
Post a Comment