forked from TestLeafPages/JavaPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseString.java
More file actions
31 lines (26 loc) · 770 Bytes
/
ReverseString.java
File metadata and controls
31 lines (26 loc) · 770 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
27
28
29
30
31
package coding;
import org.testng.annotations.Test;
public class ReverseString extends BaseTestNg{
String data ="i am going good";
// Using StringBuilder class
@Test(priority=1)
public void reverseUsingStringBuilder() {
StringBuilder input = new StringBuilder(data);
System.out.println(input.reverse());
}
// Using character array
@Test(priority=2)
public void reverseUsingCharacter() {
char[] chr = data.toCharArray();
for (int i = chr.length-1; i>=0; i--)
System.out.print(chr[i]);
System.out.println();
}
// Using character position
@Test(priority=3)
public void reverseUsingCharAt() {
for (int i = data.length()-1; i>=0; i--)
System.out.print(data.charAt(i));
System.out.println();
}
}