(Coding) Write a method on paper which takes a string as input, and if the string is even in length returns the string as-is and if not, returns the string in reverse.
Sigiloso
public class MyClass { public static void main(String args[]) { // (Coding) Write a method on paper which takes a string as input, // and if the string is even in length returns the string as-is and if not, // returns the string in reverse. String test = "testString!"; if(test.length()%2 == 0){ System.out.println(test); } else { StringBuilder stringToReverse = new StringBuilder(); stringToReverse.append(test); stringToReverse.reverse(); System.out.println(stringToReverse); } } }