java,java,java,help

java,java,java,help

Dear people, can anyone help me 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

View Answers

March 20, 2012 at 4:31 PM

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());
} 
}
}









Related Tutorials/Questions & Answers:
java,java,java,help
java,java,java,help  Dear people, can anyone help me 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

Ads