-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45802fe
commit cb0980e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.util.Scanner; | ||
|
||
class Problem_344_reverseString{ | ||
static Scanner sc = new Scanner(System.in); | ||
|
||
public static void main(String[] args) { | ||
try { | ||
String value; | ||
System.out.println("Enter String = "); | ||
value = sc.nextLine(); | ||
char arr[] = value.toCharArray(); | ||
reverse_String(arr); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
static void reverse_String(char arr[]) { | ||
char c; | ||
for (int left = 0, right = arr.length - 1; left < right; left++, right--) { | ||
c = arr[left]; | ||
arr[left] = arr[right]; | ||
arr[right] = c; | ||
} | ||
System.out.println(arr); | ||
} | ||
} |