About 162,000 results
Open links in new tab
  1. Reverse a string in Java - Stack Overflow

    Sep 10, 2017 · Since the below method (using XOR) to reverse a string is not listed, I am attaching this method to reverse a string. The Algorithm is based on : 1.(A XOR B) XOR B = A . 2.(A XOR B) XOR A = B. Code snippet:

  2. How can I reverse a single String in Java 8 using Lambda and …

    Here is another way, doesn't seem super efficient but will explain why: String s = "blast"; IntStream.range(0, s.length()).

  3. string - Reverse a given sentence in Java - Stack Overflow

    Can anyone tell me how to write a Java program to reverse a given sentence? For example, if the input is: "This is an interview question" The output must be: "question interview an is this"

  4. Reversing a String with Recursion in Java - Stack Overflow

    The function takes the first character of a String - str.charAt(0) - puts it at the end and then calls itself - reverse() - on the remainder - str.substring(1), adding these two things together to get its result - reverse(str.substring(1)) + str.charAt(0)

  5. What is the most efficient algorithm for reversing a String in Java ...

    Mar 14, 2010 · What is the most efficient way to reverse a string in Java? ... code this would be like: String reverse ...

  6. Whats the best way to recursively reverse a string in Java?

    May 14, 2009 · I have been messing around with recursion today. Often a programming technique that is not used enough. I set out to recursively reverse a string. Here's what I came up with: //A method to revers...

  7. java - Reversing a String from user's input - Stack Overflow

    The loop for (int i = length - 1; i >= 0; i--) starts with the last letter, then it takes the second last, and so on, and appends every letter in a reverse order to the reverse string. In general in the loop you will do following: reverse = reverse + original.CharAt(4) => reverse='O' reverse = reverse + original.CharAt(3) => reverse='OL'

  8. java - Displaying a string backwards using substring - Stack Overflow

    Jul 8, 2012 · Hi, as you are studying Java I recommend to check for Java classes source code too. It is a good source for learning purposes. Check file src.zip that is located in folder where you have Java installed. Unzip it and study the source code of standard java classes. –

  9. java - How do I reverse a String array? - Stack Overflow

    Nov 7, 2014 · First, you could use Arrays.toString(Object[]) to print your String[].Then you can iterate half of the array and swap the String at the current position with it's corresponding pair (at the length - current index, remembering that Java arrays are zero indexed so the last position in an array is array.length - 1).

  10. java - Reverse only letters in string and keep the same order of the ...

    With the way you currently you have it, you don't actually need to modify your method at all and can instead utilize it to reverse each word instead of the entire String at once. I renamed your current method to public static String createAnagramWord(String StringToReverse) and then created the method below:

Refresh