> For the complete documentation index, see [llms.txt](https://educacion.gitbook.io/programacion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://educacion.gitbook.io/programacion/exercicios-java/ud3-solucions/strings-e-clases-envolventes.md).

# Strings e clases envolventes

1. Palindromo

```java
public static boolean palindromo(String pal1){
        String palabra1 = pal1.toLowerCase().trim().replace(" ","");
        while (palabra1.length()>0){
            if (palabra1.charAt(0) == palabra1.charAt(palabra1.length()-1)){
                palabra1 = palabra1.substring(1,palabra1.length()-1);
            } else
                return false;
        }

        return true;
    }
```

2. cifradoDesplazamiento

```java
public static String cifradoDesplazamiento(String texto, String clave) {
		String textoCifrado = "";
		
		for (int i=0; i<texto.length(); i++) {
			char c = texto.charAt(i);
			int indice = c - 'a';;
			textoCifrado+=String.valueOf(clave.charAt(indice));
		}
		
		return textoCifrado;
	}
```

3. cifradoCesar

```java
public static String cifradoCesar(String texto) {
		String cifrado = "";
		texto.toLowerCase();
		for (int i=0; i<texto.length(); i++ ) {
			char c = texto.charAt(i);
			int pos = (c - 'a' + 5) % (26); //al ascii de la letra le sumamos 5, y calculamos el modulo en valor del numero de letras del alfabeto menos ñ
			c = (char) ('a' + pos);
			cifrado += String.valueOf(c);// que posición del alfabeto tiene la letra cifrada. Le sumamos esta posicion a la primera letra y lo convertimso a string para convertirla  
		}
		return cifrado;
	}

```

4. Anagrama

```java
public static boolean anagrama(String pal1, String pal2){
        if (pal1.length()!=pal2.length()){
            return false;
        }
        String palabra1 = pal1.toLowerCase();
        String palabra2 = pal2.toLowerCase();

        while (palabra1.length()>0){
            char c = palabra1.charAt(0);
            if (palabra2.contains(String.valueOf(c))){
                palabra1 = palabra1.substring(1,palabra1.length());
                int index = palabra2.indexOf(c);
                if (index == (palabra2.length()-1)){
                    palabra2 = palabra2.substring(0,palabra2.length()-1);
                } else {
                    palabra2 = palabra2.substring(0,index) + palabra2.substring(index+1, palabra2.length());
                }
            } else {
                return false;
            }
        }
        return true;

    }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://educacion.gitbook.io/programacion/exercicios-java/ud3-solucions/strings-e-clases-envolventes.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.
