I have to store the number 0
in a variable desc
and 1
in the variable asc
, if one of these values is found in string .
How do I do this?
package testes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Ordenar {
public static void main(String[] args) {
String desc = null;
String asc = null;
String coluna = null;
List list = new ArrayList();
String sampleString = "jrp_jasper.jrp_jas_nome|0;jrp_jasper.jrp_jas_sobrenome|1";
String[] items = sampleString.split(";");
// List<String> itemList = Arrays.asList(items);
for(int i = 0; i < items.length; i++){
if(sampleString.charAt(i) == '0'){
desc = "0";
System.out.println(desc);
}else{
asc = "1";
System.out.println(asc);
}
coluna = items[i].replaceAll("[|01]", "");
Map map = new HashMap();
map.put(coluna, asc);
list.add(coluna);
// ....