How to convert String? to String


my function returns String but in return my value is String? what should i do?


String? means that your value can be null. So you have to check that it is not null fist

if(yourResult == null){
  // handle null result, eg. throw exception, return default, etc
}  else {
  return yourResult // kotlin casts this to non null automatically

val nullString: String? = "stuff"
 println("this is your none null string ->" +it)