What is global variable explain with example?

It has a global scope means it holds its value throughout the lifetime of the program . Hence, it can be accessed throughout the program by any function defined within the program, unless it is shadowed. Example: int a =4; int b=5; public int add(){ return a+b; } Here, ‘a’ and ‘b’ are global variables.

Sizin İçin Seçtik  What is global state management in React?

Leave a Reply

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