you should know what is difference between static and non static variables
and how it behaves when its called.
 Its not problem with javac command. Please go through the static and non
static variables behavior. let me know if you have still issues.

Thanks

Srinivas

On Thu, Dec 18, 2008 at 1:29 AM, Te <[email protected]> wrote:

>
> I have created the following 3 classes. I compile using 'javac
> work.java' and the answer is 'Final Result is 2'.
>
> Next, I change the variable in "result" class from "static int count"
> to "public int count", and then I compiled again using javac
> work.java. I still get the answer of 'Final Result is 2'.
>
> Now, I delete all the classes generated and compiled again using javac
> work.java. This time, I get 'Final Result is 1'.
>
> Does this mean that javac command is not reliable. I should use
> NetBeans? (I am trying not to rely on IDE)
>
> public class work{
>        public static void main(String args[]) {
>                test t1=new test() ;
>                t1.getResult() ;
>                test t2=new test() ;
>                System.out.println("Final Result is " + t2.getResult() ) ;
>        }
> }
>
> *****************************************************************************
> public class test {
>        public test() {
>        }
>
>        int getResult() {
>                result r = new result() ;
>                r.setCount() ;
>                return r.getCount() ;
>        }
> }
>
> *****************************************************************************
> public class result {
>        static int count ;
>
>        public result() {
>        }
>
>        void setCount() {
>                count++ ;
>        }
>
>        int getCount() {
>                return count ;
>        }
> }
>
> >
>


-- 
Thanks & Regards

Srinivas
(214-597-0697)

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to