How to return a String from a Kotlin method?

How to return a String from a Kotlin method?

Use var for the Str variable that you have used here because val is like final, and you cant re-assign it.

public fun getCustomers(): String {
  var Str = ;
  val StringRequest = StringRequest(Request.Method.GET, url, Response.Listener<String> { response ->
    Str = response.toString();

  }, Response.ErrorListener {
    it.printStackTrace();
  })

  return Str;
}

How to return a String from a Kotlin method?

Leave a Reply

Your email address will not be published. Required fields are marked *