Java String Loop Assingments 1

 

public void printTwos(String str)

Description: This method prints two letters from the String starting at with the first two letters and ending with the last two.

Method Call return value/output
printTwos(“abcdef”) “ab”
“bc”
“de”
“ef”

 

 

public void printReverse(String str)

Description: This method print every letter in reverse and on a new line.

Method Call return value/output
printReverse(“abcd”) “d”
“c”
“b”
“a”
printReverse(“thefoo”) “o”
“o”
“f”
“e”
“h”
“t”
public void printTwoReverse(String str)

Description: This method print every 2 letter in reverse and on a new line.

Method Call return value/output
printTwoReverse(“abcd”) “dc”
“cb”
“ba”
printTwoReverse(“thefoo”) “oo”
“of”
“fe”
“eh”
“ht”

 

public void printTwoReverseAgain(String str)

Description: This method print every 2 letter in reverse and on a new line and with no overlap of letters

Method Call return value/output
printTwoReverseAgain(“abcd”) “dc”
“ba”
printTwoReverseAgain(“thefoo”) “oo”
“fe”
“ht”