Hello everyone, I am new to Kotlin and I am working on my first app, but I have a difficulty about calling a function.
How to call the veritable out of the function that I define in the function?
Thank you so much for your help.
The codes are below:
private fun parseItems(jsonResponse: String) {
val list = ArrayList<HashMap<String, String>>()
try {
val jobj = JSONObject(jsonResponse)
val jarray = jobj.getJSONArray("items")
val corrAns = Array(jarray.length()) { i -> " $i" }
for (i in 0 until jarray.length()) {
val jo = jarray.getJSONObject(i)
val queNo = jo.getString("queNo")
val queContent = jo.getString("queContent")
corrAns[i] = queContent
val item = HashMap<String, String>()
item["queContent"] = queContent
list.add(item)
println("This is corrAns ${corrAns[i]}.")
}
} catch (e: JSONException) {
e.printStackTrace()
}
}
...
println(arrayOf("corrAns"))
Msg from logcat:
2019-09-24 22:41:38.316 18913-18913/com.example.input_que_db I/System.out: [Ljava.lang.String;@576dfb0