
Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static String a="{a=100;b=200;c=300}"; public static void main(String args[]) { String b[]=a.split(";"); for(int i=0;i { System.out.println(b[i]); } }
here i have to split this whole String a="{a=100;b=200;c=300}" into broken tokens like a=100;b=200;c=300 so have used split method which i achieved and stored in string array b[].now have to get key value pair of this like a seperately and 100 seperately...go on.can anyone help me achieve this plz without using stringtokenizer with any collections!!!

import java.util.*;
public class StringDemo {
static String a="{a=100;b=200;c=300}";
public static void main(String args[]) {
String st=a.replace("{","");
String s=st.replace("}","");
String[] b = s.split(";");
String[][] str = new String[b.length][];
int r = 0;
for (String row : b) {
str[r++] = row.split("\\=");
}
Map<String, String> map = new HashMap<String, String>(str.length);
for (String[] array : str){
map.put(array[0], array[1]);
}
Set set = map.entrySet();
Iterator it = set.iterator();
while(it.hasNext()) {
Map.Entry me = (Map.Entry)it.next();
System.out.println(me.getKey() + ": "+me.getValue());
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.