import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
String txt = "banana";
//minuscula
// System.out.println(txt.toLowerCase());
// conviete en mayucula
// System.out.println(txt.toUpperCase());
// convertir strin en un array de caracteres
// char[] arrc = txt.toCharArray();
// System.out.println(Arrays.toString(arrc));
/*Para buscar index de primera poscion del caracter*/
//obtiene la primera couencidencia
// System.out.println(txt.indexOf("n"));
//tambien puede contar la veces que aparece una cadena
// int pos = txt.indexOf('a');
// while (pos != -1) {
// System.out.println("a en posición: " + pos);
// pos = txt.indexOf('a', pos + 1);
// }
/**/
// separa numeros de letras
// String text = "hola123";
// int index = text.indexOf("1");
// String part1 = text.substring(0, index);
// String part2 = text.substring(index);
// System.out.println(part1);
// System.out.println(part2);
// System.out.println(txt.charAt(0));
// System.out.println(txt.charAt(txt.length() -1));
// txt = "Hola mundo";
// System.out.println(txt.contains("Hola"));
for (int i = 0; i < txt.length(); i++) {
char c = txt.charAt(i);
if(txt.indexOf(c) != i){
continue;
}
int count = txt.length() - txt.replace(String.valueOf(c), "").length();
System.out.println(c + " : " + count);
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: