0

Explain about static variable in kotlin and how to declare it in kotlin?

Jun 16, 2020 in Kotlin by James

1 answers to this question.

0

Static variables are independent of objects. They are not associated with the object but are associated with the class. We can create numerous objects by using a single static member.

Declaring the static variable:

Class stat

{

Static intc;

stat()

{

C++;

}

Static voidgetc()

{

system.out.println(“number of objects=”+c);

}

Public class Exstat

{

Public static void main(String []a)

{

new stat();

new stat();

stat.getcount();

}

}

Jun 16, 2020 answered by Harshel

Related Questions

0 1 answers

Kotlin Lambda Example

Explain about kotlin lambda expression with example?

Jun 16, 2020 in Kotlin by Irshad
0 1 answers

Kotlin Abstract Class

What is the abstract class in kotlin?

Jun 16, 2020 in Kotlin by Irshad
0 1 answers

Kotlin Default Arguments

How the default argument in kotlin works?

Jun 16, 2020 in Kotlin by Irshad