-
-
Save jyhjuzi/4f26f7112cf58d9fcd2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q1_2{ | |
public static void main(String args[]){ | |
char[] test = {'a','b','c,'d','e','f'}; | |
reverse(test); | |
for(char c:test) | |
System.out.println(c); | |
} | |
void reverse(char[] str){ | |
int length=str.length; | |
for(int i = 0, j= length-1;i<j;){ | |
char temp = str[i]; | |
str[i]=str[j]; | |
str[j]=temp; | |
i++; | |
j--; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is syntax highlighting if you set your file to
Java
. It will be easier to read if so.