Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions week1/day2/classroom/string/ReverseString.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,12 @@ public class ReverseString {

public static void main(String[] args) {

// Here is the input
String test = "feeling good";

// Build the logic to find the count of each
/* Pseudo Code: 1
a) Convert the String to character array
b) Traverse through each character (using loop in reverse direction)
c) Print the character (without newline -> like below
System.out.print(ch);
*/



/* Pseudo Code: 2
a) Find the length of the string
b) Traverse through each index from length-1 -> 0 (using loop in reverse direction)
c) Find the character of the String using its index
*/
char[] charArray = test.toCharArray();
int length = test.length();
for (int i = length-1; i >=0; i--) {
System.out.println(charArray[i]);

}

}
}