//import java.util.Scanner; public class Practice01{ public static String reverse(String input) { /*Scanner sc = new Scanner(System.in); System.out.println("Give the desired string to be reversed :"); String e = sc.nextLine();*/ String result = ""; for(int i = input.length() - 1; i >= 0; i --){ result += input.substring(i , i + 1); } return result; } }
import java.util.ArrayList;import java.util.Scanner;import java.util.Collections;public class Pratice01{public static void main(String[] args) {ArrayList<Character> arr = new ArrayList<>();Scanner sc = new Scanner(System.in);- //import java.util.Scanner;
- public class Practice01{
- public static String reverse(String input) {
- /*Scanner sc = new Scanner(System.in);
- System.out.println("Give the desired string to be reversed :");
String e = sc.nextLine();int f = e.length();for(int i= 0;i<f;i++){Character d = e.charAt(i);arr.add(d);}Collections.reverse(arr);String k = "";for(Character a:arr) {String p = k+a;String z = new StringBuilder().append(p).toString();System.out.print("Reversed string"+z);}- String e = sc.nextLine();*/
- String result = "";
- for(int i = input.length() - 1; i >= 0; i --){
- result += input.substring(i , i + 1);
- }
- return result;
- }
- }
import static org.junit.Assert.*; import org.junit.Test; // TODO: Replace examples and use TDD by writing your own tests public class Practice01Test { private static void testing(String actual, String expected) { assertEquals(expected, actual); } @Test public void test() { testing("!ereht olleH" , Practice01.reverse("Hello there!")); } }
import org.junit.jupiter.api.Test;import static org.junit.jupiter.api.Assertions.assertEquals;- import static org.junit.Assert.*;
- import org.junit.Test;
- // TODO: Replace examples and use TDD by writing your own tests
- public class Practice01Test {
class SolutionTest {- private static void testing(String actual, String expected) {
- assertEquals(expected, actual);
- }
- @Test
void testSomething() {// assertEquals("expected", "actual");- public void test() {
- testing("!ereht olleH" , Practice01.reverse("Hello there!"));
- }
- }