I'm trying to create a key => value Hashmap.
First, I have a string delimited by <br />. Then, I split it with split() (to get each string independently).
Then, I need to split each result with "=". The first part will be the key (I need it to be a string) and the second one will be the value (an int)
For now I have
val formules = objInput.getString(Constants.formules)
val hashmap = HashMap<String, Int>()
val resSplit = formules.split("<br />")
resSplit.forEach {
val splitFormule = it.split(" = ")
val key = splitFormule.elementAt(0)
val value = splitFormule.elementAt(1)
Log.i(TAG, "$key")
}
I have this error when I'm trying to display the value :
Index: 1, Size: 1
splitFormulecontains only one element. Check it.