- 1

Where exactly can I declare variables?

I can declare it whereever I want. Do I understand right?

24th Nov 2016, 12:50 PM
Nochains
Nochains - avatar
4 Respostas
+ 5
Yes you can define variable wherever you want but should be in a class. Also scope of variables different. Like if you define your variable outside of any method in class it will global. define inside of method of a class it will local
24th Nov 2016, 12:56 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
it musst be in class of course :)
24th Nov 2016, 12:57 PM
Ozan Karataş
Ozan Karataş - avatar
+ 1
it must be in that class or object or the functions otherwise it would not work if called from other but if you need to call it from all you can use declaration by global scope
24th Nov 2016, 5:30 PM
Sandeep Chatterjee
+ 1
thanks
24th Nov 2016, 6:25 PM
Nochains
Nochains - avatar