Class ReverseArray{
public static void main(String args[]){
char inputArray[]=args[0].toCharArray();
reverseArray(inputArray);
String outputString=String.copyValueOf(inputArray);
System.out.println(outputString);
}
private static void reverseArray(char[] inputArray){
for(int i=0;i<(inputArray.length)/2;i++){
char temp=inputArray[i];
inputArray[i]=inputArray[inputArray.length-1-i];
inputArray[inputArray.length-1-i]=temp;
}
}
}
Here user run :java ReverseArray shakti
output will be : itkahs
Its really Help ful for me
ReplyDeleteThis question really helps in the interview.thanks for posting this programe
ReplyDelete