tag:blogger.com,1999:blog-7258332205026269340.post322230509392112835..comments2024-02-21T01:43:44.367-08:00Comments on Selenium-By-Arun: 46. Scope of VariablesPriyanka Motoorihttp://www.blogger.com/profile/04643338373711611455noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7258332205026269340.post-11746875679775240402014-07-10T00:05:16.443-07:002014-07-10T00:05:16.443-07:00@Divya - The variable 'a' is declared insi...@Divya - The variable 'a' is declared inside the if( ) condition statement. As the scope of variable 'a' starts from the starting brace '{' of the if( ) condition statement. The variable 'a' is not visible to the if(a>0) condition statement. Declare the variable int a = 5; outside the if(a>0){ } and your error will get resolved. Arun Motoorihttps://www.blogger.com/profile/18156045285817519369noreply@blogger.comtag:blogger.com,1999:blog-7258332205026269340.post-57534141695367251342014-07-09T23:40:38.154-07:002014-07-09T23:40:38.154-07:00Hi Arun,
I have executed the below code:
class Ou...Hi Arun,<br /><br />I have executed the below code:<br />class OuterScopeObject<br />{<br /> public static void main(String args[])<br /> { // Outer scope started<br /> <br /><br /> if(a>0) <br /> { // Inner scope started<br />Anonymoushttps://www.blogger.com/profile/11937153342173570870noreply@blogger.com