forked from codehouseindia/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse.java
More file actions
26 lines (21 loc) · 764 Bytes
/
Copy pathreverse.java
File metadata and controls
26 lines (21 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# https://www.facebook.com/jyotiprakash.nayak.372/posts/1837128093092133
# subscibed by Code House
import java.lang.*;
import java.io.*;
import java.util.*;
// Class of ReverseString
class ReverseString {
public static void main(String[] args)
{
String input = "GeeksforGeeks";
// getBytes() method to convert string
// into bytes[].
byte[] strAsByteArray = input.getBytes();
byte[] result = new byte[strAsByteArray.length];
// Store result in reverse order into the
// result byte[]
for (int i = 0; i < strAsByteArray.length; i++)
result[i] = strAsByteArray[strAsByteArray.length - i - 1];
System.out.println(new String(result));
}
}