0

What is scope of data structure ?

is this compulsory to learn it ?

22nd Mar 2017, 7:48 PM
Abhishek Tiwari
Abhishek Tiwari - avatar
1 Answer
+ 12
Definitely, it's important! Scope refers to where you can use a data structure, variable, or method. Some people describe it as it's "lifespan". It depends on where and how you define it. For example, let's say you write a for loop: for (int i = 0; i < 10; i++) { //Your code } You're only able to use the i counter in the for loop (inside the {}). i's scope only last for the duration of the for. A variable made inside a method only last inside that method. Methods only last inside the class they're in. Global items last for the entire program.
22nd Mar 2017, 7:57 PM
Tamra
Tamra - avatar