> For the complete documentation index, see [llms.txt](https://www.onee.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.onee.io/blog/leetcode-shua-ti-zhi-l/344.-reverse-string.md).

# 344. Reverse String

> **题目大意：**&#x8F93;入一个字符串，返回字符串的反转，例如输入“hello”，返回“olleh”

#### 344. Reverse String

Write a function that takes a string as input and returns the string reversed.

**Example:**

Given s = "hello", return "olleh".

```java
public String reverseString(String s) {
    char[] c = s.toCharArray();
    char temp;
    int startIndex = 0;
    int endIndex = c.length - 1;
    while (endIndex > startIndex) {
        temp = c[startIndex];
        c[startIndex] = c[endIndex];
        c[endIndex] = temp;
        startIndex ++;
        endIndex --;
    }
    return new String(c);
}
```
