...

/

Solution Review: Playing With Strings

Solution Review: Playing With Strings

In this review, solution of the challenge 'Playing With Strings' from the previous lesson is provided.

Solution: To be upper case or not to be? #

Press + to interact
class challenge_four {
public static String test(String x) {
if (x.length() % 2 == 0) {
return x.toUpperCase();
}
return x.toLowerCase();
}
public static void main( String args[] ) {
String odd = "Hello";
String even = "John";
System.out.println( "Hello:" + test(odd));
System.out.println( "John:" + test(even));
}
}

Understanding the code

...