-3
            for (int i = 0, len = input.length(); i < len; i++) {
                char ch = input.charAt(i);
                if (i % 2 == 0) {
                    System.out.print(Character.toLowerCase(ch));
                } else {
                    System.out.print(Character.toUpperCase(ch));

                }
            }

I want to do this without using the character class. Only using tolowerCase and toUpperCase and basic loops.

So, the basic program would be converting a string like "Hello World" to "HeLlo WoRlD" without using the character class.

I'm told you can do it, but I can't figure it out. It's really bugging me

1 Answers1

0

I figured it out. It would just be this:

            for (int i = 0, len = input.length(); i < len; i++) {

                char ch = input.charAt(i);
                String str = ch + ""; //<- converts char to a string!

                if (i % 2 == 0) {
                    System.out.print(str.toLowerCase());
                } else {
                    System.out.print(str.toUpperCase());

Not sure why this got downvoted so much, I spent like an hour on google looking for something like this. I guess I suck at google.