Amar B.

asked • 10/26/22

Java coding challenges

My code is below and I'm wondering how to print Take Care like ekaT eraC but it doesn't print that way.




public class challenge4 {

public static String everyOtherWordBackwards(String str)

{

String reversed = "";

for(int i = 0; i < str.length(); i++)

{

String single = str.substring(i, + i + 1);

reversed = reversed + single;

}

System.out.println("The original is: " + str);

System.out.println("The new is: " + reversed);

return reversed;


public static void main(String[] args)

{

String str = "Take Care";

everyOtherWordBackwords(str);

}

}



1 Expert Answer

By:

Tyler M. answered • 10/28/22

Tutor
0 (0)

Java and Math Tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.