What's Here?
- Members: 306,725
- Replies: 840,900
- Topics: 140,492
- Snippets: 4,465
- Tutorials: 1,165
- Total Online: 2,591
- Members: 130
- Guests: 2,461
|
This snippet returns the reverse of the given input from the beginning to the character at index.
|
Submitted By: macosxnerd101
|
|
|
Rating:
|
|
Views: 185 |
Language: Java
|
|
Last Modified: November 2, 2009 |
|
Instructions: Make sure index is < input.length()-1 |
Snippet
//if the index is at the beginning, return the first character
if(index == 0) return input.charAt(0) + "";
//otherwise, return the character at index plus the character
//immediately to the left
return input.charAt(index) + reverse(input, index-1);
}
Copy & Paste
|
|
|
|