Chapter 11 · SimulationString Lab? ← Chapter 11 ◀ Back Step ▶ Play Reset CloseString LabPurpose: see the characters and indices of a String object, what the basic methods return, immutability (every “change” produces a new object) and the difference between == and equals on a memory diagram.How to use itPick an operation; change the string and the parameters (a, b, x, y, Locale) and press Apply. Random sometimes produces an invalid index too.Move on with Step ▶ (or →). At the top you see the cells and indices of the string, on the right the memory diagram (variables → objects in the string pool / heap), and at the bottom the result. A newly created object is orange; an object that no variable refers to is faded and dashed.In the substring(a, b) step the orange lines show the indices as boundaries between the characters: a inclusive, b exclusive; the length of the result is b − a.With Try it yourself on, you predict the result first (type string results without quotes; if you expect an error, type error).RemindersValid indices are 0 … length() − 1; a charAt or substring outside them throws StringIndexOutOfBoundsException. The message format is that of Java 21; older versions word it differently.toUpperCase() without a parameter depends on the machine's default language. In Turkish i → İ and I → ı; with Locale.ENGLISH it is i → I, İ → i̇ (2 characters!).The split parameter is a regular expression; this lab does not accept separators containing . | * + ? ( ) [ ] { } ^ $ \. Trailing empty pieces are discarded.If nothing changes (e.g. a replace that finds nothing, substring(0)) the JDK returns the same object; in the diagram the arrow goes to the same object. In no case does the content of s change.Related slides: Chapter 11 · Strings (indexing, basic methods, substring bounds, == versus equals, Turkish characters and Locale, concatenation and StringBuilder).