Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/25-strings/10-quotes/en/EXERCISE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

Write a program that displays:

text
```text

Check notice on line 4 in modules/25-strings/10-quotes/en/EXERCISE.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/EXERCISE.md#L4

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/EXERCISE.md:4:8: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
"Khal Drogo's favorite word is "athjahakar""
```

The program should display this phrase exactly. Note the quotes at the beginning and at the end of a phrase.
The program should display this phrase exactly. Note the quotes at the beginning and at the end of the phrase.
90 changes: 80 additions & 10 deletions modules/25-strings/10-quotes/en/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,107 @@
Strings in Java appear at every step. We use them to work with text, print messages to the screen, process user input, and exchange data with external systems.

From Java's point of view, a string is a set of characters enclosed in double quotes. Let's look at some examples.

```java
"Hello"
"Goodbye"

"G"
" "
""
```

Which of these five options are strings?
All of these are strings.

- `"Hello"` and `"Goodbye"` are strings of several characters
- `"G"` is a string of a single character
- `" "` is a string of a single space

Check notice on line 17 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L17

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:17:3: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 17 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L17

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:17:5: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
- `""` is an empty string, it contains no characters at all. It plays the same role as 0 in mathematics

Everything inside the quotes is considered a string, even if it's just a space or nothing at all.

If you print these strings to the screen, `"Hello"` and `"Goodbye"` will be clearly visible. But `" "` and `""` are confusing. Printing an empty string looks like a complete absence of text, while a string with a space shows an "empty spot" that is visually hard to tell apart from emptiness. Java clearly distinguishes between these cases. An empty string means the absence of characters, while a string with a space contains a specific space character.

Check notice on line 22 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L22

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:22:98: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 22 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L22

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:22:100: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

A control question. Are these the same strings or not?

```java
"hexlet"
" hexlet"

Check notice on line 28 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L28

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:28:8: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
```

## Terminology. String or line?

In programming there is a terminological trap.

- A string is a data type, that same set of characters in quotes, for example `"hello"`
- A line is a line of text in a file or in code

For example, the code below has a line but no string.

```java
System.out.println(5);
```

To avoid confusion, in this course we will stick to the following wording.

- String, when we talk about the data type
- Line, when we talk about lines of code

Everything is clear with the first two, these are exactly strings, we have already worked with similar constructions and said that strings are character sets.
## Only double quotes

Any single character in quotes is a string. The empty string `" "` is also a string. That is, we consider everything to be inside the quotes, even if it is a space, one character or no characters at all.
In some languages, strings can be written in both single and double quotes. In Java, a string is always enclosed in double quotes `"`.

Imagine that you want to print _dragon's mother_ line. The apostrophe before the letter **s** is the same character as a single quote. Let's try:
```java
System.out.println("Hello");
```

Single quotes also appear in Java, but that's a completely different story. A notation like `'A'` denotes a single character, not a string. So when it comes to text, we use only double quotes.

This version of the program will work correctly:
## The problem with quotes inside a string

Imagine you want to print the phrase *Dragon's mother*. It contains an apostrophe (*'s*), which matches the single quote character. Since the string is bounded by double quotes, the apostrophe inside it doesn't cause any trouble.

```java
System.out.println("Dragon's mother");
// => Dragon's mother
```

And what if we want to create such a string:

Java understands that a single quote inside a string is an ordinary character. A string starts and ends with double quotes, and everything between them is considered its content.

The difficulties begin when you need the double quotes themselves inside the string. Imagine we want to print the following text:

```text
Dragon's mother said "No"
```

It contains both single and double quotes. How to be in this situation?
If you insert double quotes directly inside the string, the program won't compile.

```java
// Ends with a syntax error
System.out.println("Dragon's mother said "No"");

Check notice on line 80 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L80

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:80:19: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 80 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L80

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:80:45: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
```

From Java's point of view, this results in a strange construction of three parts.

- The string `"Dragon's mother said "`

Check notice on line 85 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L85

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:85:14: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 85 in modules/25-strings/10-quotes/en/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/en/README.md#L85

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/en/README.md:85:36: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
- The word `No`, which is not in quotes and therefore is not considered a string
- The empty string `""`

Java will decide that the first string ends before the word *No*, and then comes incomprehensible code. This is what causes the error.

To do this, use the **escape character**: `\`. If you put `\` before the quotation mark (single or double), it will mean that the quotation mark should be viewed not as the beginning or end of the line, but as part of the line.
## The escape character

To place a double quote inside a string, you escape it with a backslash `\`. It tells the compiler that the character following it is part of the string, not the string's boundary.

```java
System.out.println("Dragon's mother said \"No\"");
// => Dragon's mother said "No"
```

Here we escape the double quotes inside a string enclosed in double quotes. Java treats `\"` as a single quote character, not as two separate characters. Such notations are called escape sequences.

To print the backslash itself, you also escape it with a second slash.

```java
System.out.println("\\");
// => \
```
5 changes: 4 additions & 1 deletion modules/25-strings/10-quotes/en/data.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
name: quotes
name: Quotes
tips:
- >
[Strings in Java](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html)
4 changes: 2 additions & 2 deletions modules/25-strings/10-quotes/es/EXERCISE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

Escribe un programa que imprima en la pantalla:
Escribe un programa que muestre en la pantalla:

```text
"Khal Drogo's favorite word is "athjahakar""
```

El programa debe imprimir exactamente esta frase. Presta atención a las comillas al principio y al final de la frase.
El programa debe mostrar esta frase exactamente. Presta atención a las comillas al principio y al final de la frase.
99 changes: 81 additions & 18 deletions modules/25-strings/10-quotes/es/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,107 @@
Las cadenas de texto en Java aparecen a cada paso. Con su ayuda trabajamos con texto, mostramos mensajes en la pantalla, procesamos la entrada del usuario e intercambiamos datos con sistemas externos.

Desde el punto de vista de Java, una cadena de texto es un conjunto de caracteres encerrado entre comillas dobles. Veamos algunos ejemplos.

```java
"Hola"
"Adiós"
"Hello"
"Goodbye"
"G"
" "
""
```

¿Cuáles de estas cinco opciones son cadenas de texto? Con las primeras dos está claro: son definitivamente cadenas de texto, ya hemos trabajado con construcciones similares. ¿Pero qué pasa con las demás?
Todas estas variantes son cadenas de texto.

- `"Hello"` y `"Goodbye"` son cadenas de varios caracteres
- `"G"` es una cadena de un solo carácter
- `" "` es una cadena de un solo espacio

Check notice on line 17 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L17

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:17:2: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 17 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L17

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:17:4: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
- `""` es una cadena vacía, no contiene ningún carácter. Cumple el mismo papel que el 0 en matemáticas

Todo lo que está dentro de las comillas se considera una cadena de texto, aunque solo haya un espacio o nada en absoluto.

Si mostramos estas cadenas en la pantalla, `"Hello"` y `"Goodbye"` se verán con claridad. En cambio, `" "` y `""` resultan confusas. Mostrar una cadena vacía se ve como una ausencia total de texto, mientras que una cadena con un espacio muestra un "espacio vacío" que visualmente es difícil de distinguir del vacío. Java distingue con claridad estos casos. Una cadena vacía significa la ausencia de caracteres, mientras que una cadena con un espacio contiene un carácter de espacio concreto.

Check notice on line 22 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L22

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:22:96: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 22 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L22

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:22:98: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Pregunta de control. ¿Son iguales estas cadenas o no?

```java
"hexlet"

Check notice on line 27 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L27

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:27:3: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
" hexlet"
```

## Terminología. ¿Cadena o línea?

Cualquier carácter individual entre comillas es una cadena de texto. Una cadena de texto vacía `""` también es una cadena de texto. Es decir, consideramos como cadena de texto todo lo que está dentro de las comillas, incluso si es un espacio, un solo carácter o la ausencia total de caracteres.
En programación existe una trampa terminológica.

Imagina que quieres imprimir la frase *la madre del dragón*. El apóstrofe antes de la letra **s** es un carácter igual que una comilla simple. Intentemos. Esta versión del programa funcionará correctamente:
- Una cadena (string) es un tipo de dato, ese mismo conjunto de caracteres entre comillas, por ejemplo `"hello"`
- Una línea (line) es una línea de texto en un archivo o en el código

Por ejemplo, en el código de abajo hay una línea, pero no una cadena.

```java
System.out.println("La madre del dragón");
System.out.println(5);
```

Pero, ¿qué pasa si queremos crear una cadena de texto como esta:
Para no confundirnos, en este curso nos atendremos a las siguientes formulaciones.

- Cadena, cuando hablamos del tipo de dato
- Línea, cuando hablamos de las líneas de código

## Solo comillas dobles

En algunos lenguajes las cadenas se pueden escribir tanto con comillas simples como con comillas dobles. En Java una cadena siempre se encierra entre comillas dobles `"`.

```java
System.out.println("Hello");
```

Las comillas simples también aparecen en Java, pero esa es una historia completamente distinta. Una notación como `'A'` representa un solo carácter, no una cadena. Por eso, cuando se trata de texto, usamos solo comillas dobles.

## El problema con las comillas dentro de una cadena

Imagina que quieres imprimir la frase *Dragon's mother*. En ella hay un apóstrofo (*'s*), que coincide con el carácter de comilla simple. Como la cadena está delimitada por comillas dobles, el apóstrofo que hay dentro no molesta.

```java
System.out.println("Dragon's mother");
// => Dragon's mother
```

Java entiende que una comilla simple dentro de una cadena es un carácter corriente. La cadena empieza y termina con comillas dobles, y todo lo que hay entre ellas se considera su contenido.

Las dificultades empiezan cuando dentro de la cadena hacen falta las propias comillas dobles. Imagina que queremos mostrar el siguiente texto:

```text
La madre del dragón dijo "No"
Dragon's mother said "No"
```

En ella hay tanto comillas simples como comillas dobles. ¿Qué hacer en esta situación? Si simplemente intentamos imprimir esta cadena de texto, obtendremos un error:
Si insertamos las comillas dobles directamente dentro de la cadena, el programa no compilará.

```java
// Terminará con un error de sintaxis
System.out.println("La madre del dragón dijo "No"");
// Termina con un error de sintaxis

Check notice on line 79 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L79

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:79:19: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
System.out.println("Dragon's mother said "No"");

Check notice on line 80 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L80

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:80:9: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
```

Desde el punto de vista de Java, esta es una construcción extraña de dos componentes de tres:
Desde el punto de vista de Java, aquí resulta una construcción extraña de tres partes.

Check notice on line 83 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L83

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:83:65: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

Check notice on line 83 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L83

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:83:87: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

- La cadena `"Dragon's mother said "`
- La palabra `No`, que no está entre comillas y por eso no se considera una cadena
- La cadena vacía `""`

Java decidirá que la primera cadena termina antes de la palabra *No*, y a continuación viene código incomprensible. Eso es lo que provoca el error.

## El carácter de escape

- La cadena de texto *"La madre del dragón dijo "*
- La cadena de texto *""*
- La palabra *No* entre ellos, que no se considera una cadena de texto porque no está entre comillas
Para colocar una comilla doble dentro de una cadena, se la escapa con una barra invertida `\`. Le indica al compilador que el carácter que le sigue es parte de la cadena, no el límite de la cadena.

Check notice on line 93 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L93

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:93:181: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION

```java

Check notice on line 95 in modules/25-strings/10-quotes/es/README.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] modules/25-strings/10-quotes/es/README.md#L95

Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES) URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US Category: PUNCTUATION
Raw output
modules/25-strings/10-quotes/es/README.md:95:3: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
 URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses 
 Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
 Category: PUNCTUATION
System.out.println("Dragon's mother said \"No\"");
// => Dragon's mother said "No"
```

No se puede imprimir esta cadena de texto de la manera habitual. Para imprimir cadenas de texto como esta, se utiliza el **carácter de escape**: `\`.
Aquí escapamos las comillas dobles dentro de una cadena encerrada entre comillas dobles. Java interpreta `\"` como un único carácter de comilla, no como dos caracteres separados. Estas notaciones se llaman secuencias de escape.

Si colocamos `\` antes de una comilla, significa que la comilla debe considerarse como parte de la cadena de texto, no como el inicio o el final de la misma:
Para mostrar la propia barra invertida, también se la escapa con una segunda barra.

```java
System.out.println("La madre del dragón dijo \"No\"");
System.out.println("\\");
// => \
```
3 changes: 3 additions & 0 deletions modules/25-strings/10-quotes/es/data.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
name: Comillas
tips:
- >
[Cadenas en Java](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html)
6 changes: 3 additions & 3 deletions modules/25-strings/15-escape-characters/en/EXERCISE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Write a program that displays:

Did Joffrey agree?
He did. He also said "I love using \n".
- Did Joffrey agree?
- He did. He also said "I love using \n".

The program uses only one `println`, but the result on the screen should look exactly like the one shown above.
The program uses only one `System.out.println()`, but the result on the screen should look exactly as shown above.
Loading
Loading