logo-MindMajix
PostKotlinKotlin
j
jordan chris

Posted on 24th July 2024|40 views

0
votes

Kotlin Instance Of

How can we check the class instance of in kotlin?

1 answers
Answers
P
Harshel Mike

Posted on 24th July 2024| views

Class "instance of" can be checked by using the keyword is or !is

A simple example is given below: 

if(myInstance is string)

{

print(string)

}

if(myInstance !is string)

{

print(not a string)

}

else

{

print(null)

}

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number