Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


Clase String: Propiedades y Métodos, Diapositivas de Programación Java

La clase String en Java, sus operadores básicos y métodos como length, indexOf, charAt, equals, compareTo, replaceAll, toLowerCase, toUpperCase y substring. Además, explica cómo manejar citas invertidas y caracteres de escape.

Tipo: Diapositivas

2020/2021

Subido el 10/01/2021

carlosmo1004
carlosmo1004 🇪🇸

2 documentos

1 / 8

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
Kyb ele
Research
Group
IV: Strings
pf3
pf4
pf5
pf8

Vista previa parcial del texto

¡Descarga Clase String: Propiedades y Métodos y más Diapositivas en PDF de Programación Java solo en Docsity!

Kybele Research Group IV: Strings

Clase String

Allows the creation of objects which chains of chars

Basic Operators

String x, y, z; String myName = “Paul”; x = “Móstoles”; x = “Manuel Becerra”; // Móstoles desaparece y = x; // y contendrá Manuel Becerra x = “”; // x ahora es una cadena vacía String x, y; x = “Hola ”; y = “Mundo”; System.out.println(x+y); // x.concat(y) System.out.println(“La suma total es: ” + 25 + 30); System.out.println(“La suma total es: ” + (25 + 30)); ¿?

Clase String: Métodos

int length()

  • Length of the string

int indexOf(String cad)

  • This method returns the index within this string of the first occurrence of the specified character or - 1, if the character does not occur.

char charAt(int ind)

  • This method returns the character located at the String's specified index. The string indexes start from zero.

Clase String: Métodos Boolean equals(String cad)

  • This method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object int compareTo(String cad)
  • This method compares two strings lexicographically
  • 0 if the argument is a string lexicographically equal to this string
  • < 0 if the argument is a string lexicographically greater than this string
  • 0 if the argument is a string lexicographically less than this string.

Clase String: Métodos

String substring(int indexInicial,

int indexFinal)

  • This method has two variants and returns a new string that is a substring of this string.
  • The substring begins with the character at the specified index and extends to - the end of this string or - up to endIndex – 1, if the second argument is given.

Kybele Research Group IV: Strings