# \[course04] 03 Advance String

### literator

```java
String str = "asdfghjkl";
for (int i = 0; i < str.length(); i++) {
    char ch = str.charAt(i);
}

// efficient
char[] c = str.toCharArray();
for (char cc : c) {
    print(cc);
}

// inefficiency
for (int i = 0; i < str.length(); i++) {
    String subStr = str.substring(i, i + 1);
}
```

### String concatenation has the same precedence as + and -, and is evaluated left to right.

![](https://ossp.pengjunjie.com/mweb/16384793688185.jpg)

### Every character has a corresponding integer value

* A variable of type char holds exactly one (Unicode) character/symbol.
* The digit characters '0'… '9' have consecutive integer values, as do the letters 'A'… 'Z' and 'a'… 'z'. Java uses this ordering to sort lexigraphically.

Conversions:

![](https://ossp.pengjunjie.com/mweb/16384795984907.jpg)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.uxres.com/collapsar-java-baisc/course04-string-and-build-in-functions/course04-03-advance-string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
