I am trying to make a code using hashmaps such that if a user types the following string: "put(k,v)" and presses enter, I will add the corresponding key-value pair into the hashmap M. (K and V are both strings of variable length).
but the issue is, how can I get that "k" and "v" value to put into a different variable, so that I can use the command M.put("k","v")?
Currently, my main idea is to run a for loop through the entire string, and when I hit "(", start collecting each character into a s1 string until ",", then start collecting each character into another s2 string until ")", but this is very tedious and I'm not even sure if it will work properly.
Are there any easier, more convenient ways to do this?