I have the following string in Java. For Example:
String abc = "nama=john; class=6; height=170; weight=70";
How can I extract the value of height from the String?
Outputs: height=170
This is the code I have written so far:
String abc = "nama=john; class=6; height=170; weight=70";
String[] tokens = abc.split("; ");
List<String> listString = new ArrayList<String>();
String mod = new String();
for (String s : tokens) {
mod = s;
System.out.println(s);
listString.add(mod);
}
System.out.println(listString.size());
But I do not get the value height. Instead, I get value of height as a String.
Thanks.