Skip to main content

We willLet's analyze your program first.. In your program, your first method is main()main(),and and keep it in mind it is the static method..then. Then you declare the local variable for that method (compareCount,low low, high,etc etc..).Scope The scope of this variable is only with in the declared method record less, regardless of it isbeing a static or non static method.So So you can't use those variables out sideoutside that method..This This is the basic error u did.made.

Then we'llwe come to next point..you You told static is killing you..  (It may killsbe killing you but it'sit only gives life to your program..!!)first u First you must understand the basic thing.. *static*Static method calls only the static method..and only and use only the static variable.. *static*Static variable or static method are not dependdependent on any instance of that class..  (ie,if ui.e. If you change any state of the static variable it will reflectsreflect in all objects of the class).. *Because of this u calyou call it as a class variable andor a class method.. And Lota lot more is there about static.the "static" keyword. iI hope now u got someyou get the idea..first First change the scope of the variable and declare it as a static  (because ofto be able to use it in static methods)..

And the directionadvice for you is..,you missed: you misunderstood the idea of the scope of the variables and static functionalities..get Get clear idea about that..

We will analyze your program first.. In your program your first method is main(),and keep it in mind it is the static method..then you declare the local variable for that method (compareCount,low, high,etc..).Scope of this variable is only with in the declared method record less of it is static or non static method.So you can't use those variables out side that method..This is the basic error u did..

Then we'll come to next point..you told static is killing you..(It may kills you but it's only gives life to your program..!!)first u understand the basic thing.. *static method calls only the static method..and only use the static variable.. *static variable or static method are not depend on any instance of that class..(ie,if u change any state of static variable it will reflects in all objects).. *Because of this u cal it as class variable and class method.. And Lot more is there about static.. i hope now u got some idea..first change the scope of the variable and declare it as a static(because of to use it in static methods)..

And the direction for you is..,you missed the idea of scope of the variables and static functionalities..get clear idea about that..

Let's analyze your program first.. In your program, your first method is main(), and keep it in mind it is the static method... Then you declare the local variable for that method (compareCount, low, high, etc..). The scope of this variable is only the declared method, regardless of it being a static or non static method. So you can't use those variables outside that method. This is the basic error u made.

Then we come to next point. You told static is killing you.  (It may be killing you but it only gives life to your program!!) First you must understand the basic thing. *Static method calls only the static method and use only the static variable. *Static variable or static method are not dependent on any instance of that class.  (i.e. If you change any state of the static variable it will reflect in all objects of the class) *Because of this you call it as a class variable or a class method. And a lot more is there about the "static" keyword. I hope now you get the idea. First change the scope of the variable and declare it as a static  (to be able to use it in static methods).

And the advice for you is: you misunderstood the idea of the scope of the variables and static functionalities. Get clear idea about that.

Source Link

We will analyze your program first.. In your program your first method is main(),and keep it in mind it is the static method..then you declare the local variable for that method (compareCount,low, high,etc..).Scope of this variable is only with in the declared method record less of it is static or non static method.So you can't use those variables out side that method..This is the basic error u did..

Then we'll come to next point..you told static is killing you..(It may kills you but it's only gives life to your program..!!)first u understand the basic thing.. *static method calls only the static method..and only use the static variable.. *static variable or static method are not depend on any instance of that class..(ie,if u change any state of static variable it will reflects in all objects).. *Because of this u cal it as class variable and class method.. And Lot more is there about static.. i hope now u got some idea..first change the scope of the variable and declare it as a static(because of to use it in static methods)..

And the direction for you is..,you missed the idea of scope of the variables and static functionalities..get clear idea about that..