Nuovo rimuoviCarattere
This commit is contained in:
parent
d82ae7305e
commit
1dd40427ae
@ -12,7 +12,7 @@ import java.util.LinkedList;
|
|||||||
* @author Verde
|
* @author Verde
|
||||||
*/
|
*/
|
||||||
public class GestisciStringhe {
|
public class GestisciStringhe {
|
||||||
public static int ContaOccorrenze(String testo, String testoDaCercare) {
|
/*public static int ContaOccorrenze(String testo, String testoDaCercare) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class GestisciStringhe {
|
|||||||
|
|
||||||
public static char estraiCarattere(String testo, char tipo, int nrOccorrenza) {
|
public static char estraiCarattere(String testo, char tipo, int nrOccorrenza) {
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public static boolean isVocale(char carattere) {
|
public static boolean isVocale(char carattere) {
|
||||||
carattere = Character.toLowerCase(carattere);
|
carattere = Character.toLowerCase(carattere);
|
||||||
@ -50,9 +50,9 @@ public class GestisciStringhe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String rimuoviCarattere(String testo, String carattere) {
|
public static String rimuoviCarattere(String testo, String carattere) {
|
||||||
|
StringBuilder bld = new StringBuilder();
|
||||||
char[] testoOriginale = testo.toCharArray();
|
char[] testoOriginale = testo.toCharArray();
|
||||||
LinkedList<Character> testoRipulito = new LinkedList<>();
|
LinkedList<Character> testoRipulito = new LinkedList<>();
|
||||||
String ritorno;
|
|
||||||
|
|
||||||
for (int i = 0; i < testoOriginale.length; i++) {
|
for (int i = 0; i < testoOriginale.length; i++) {
|
||||||
if (testoOriginale[i] != carattere.toCharArray()[0]) {
|
if (testoOriginale[i] != carattere.toCharArray()[0]) {
|
||||||
@ -60,8 +60,17 @@ public class GestisciStringhe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ritorno = Arrays.toString(testoRipulito.toArray());
|
Object[] testoRipulitoArray = testoRipulito.toArray();
|
||||||
|
char[] testoRipulitoArrayChar = new char[testoRipulitoArray.length];
|
||||||
|
|
||||||
return ritorno;
|
for (int i = 0; i < testoRipulitoArray.length; i++) {
|
||||||
|
testoRipulitoArrayChar[i] = (char) testoRipulitoArray[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (char c : testoRipulitoArrayChar) {
|
||||||
|
bld.append(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bld.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user