12
How can I check whether at the end of a string is 0
?
The problem with this code is that the string may contain:
jrp_documento.jrp_doc_001fornecedor|0
My need is to check if at the end of the string is 1
or 0
.
I identified another problem as well. Like this string is the table name in the database it is necessary to stay equal to table, I give replaceAll
there in the 0
hold back 0
, but if the string contain 0
he withdraws and is not to withdraw unless the 0
is at the end. What I do?
public static void main(String[] args) {
String nomeColuna = null;
String coluna = null;
String sampleString = "jrp_documento.jrp_doc_fornecedor|0";
String[] items = sampleString.split(";");
List<String> itemList = Arrays.asList(items);
for(int i = 0; i < itemList.size(); i++){
coluna = items[i].replaceAll("[|]", "");
coluna = coluna.replaceAll("[.]", "_");
if(coluna.contains("0")){
nomeColuna = coluna.replaceAll("0", "");
System.out.println(nomeColuna);
System.out.println(" é zero ");
}else{
nomeColuna = coluna.replaceAll("1", "");
System.out.println(nomeColuna);
System.out.println(" é um ");
}
}
You need to check if items has 0 at the end?
– user28595
Yes that’s right, and it cannot modify the other zeros that the String has, only remove the zero or one of the same end...
– Aline