GoConqr has a new look! Let us know what you think.

Module 3 of 10 · Text

Métodos de manipulação

Brenda Gabriela Senra da Silva

Trim(): O método trim() remove espaços em branco no começo e no fim da String

toLowerCase()

toUpperCase

replace(): O método replace() substitui parte de uma String por outra. Ex: texto.replace("antigo", "novo");

charAt(): O método charAt() pega um caractere específico de uma String

String texto = "Java";

System.out.println(texto.charAt(0));
System.out.println(texto.charAt(1));

 

Substring(): O método substring() pega uma parte da String

 

Sintaxe

1️⃣ Com 1 parâmetro

texto.substring(inicio);

👉 pega do índice até o final

2️⃣ Com 2 parâmetros

texto.substring(inicio, fim);

👉 pega do índice inicio até antes do fim

 

Contains(): O método contains() verifica se uma String contém outra

texto.contains("palavra");

 

👉 retorna:

  • true → se encontrou
  • false → se não encontrou

 

startsWith(): O método startsWith() verifica se a String começa com um texto específico

texto.startsWith("palavra");

 

retorna:

  • true → se começa com isso
  • false → se não

endsWith(): O método endsWith() verifica se uma String termina com um texto específico

texto.endsWith("final");

 

parei no 5:23

 

 

 

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?