Please post the complete code so that it would be easy to understand. e.g.
1) I do not see any main method, so I'm assuming that the code given under mainClass.java is inside main method.
2) What is '2' in first for loop of mainClass? Please avoid using magic numbers (or at least give them a meaningful variable names)
3) What is 'size'? Whose size it is?
Anyway, apart from those, lets get to your question - why numThread and Length print 0 (one more thing - please follow naming conventions - class names start with Uppercase letter, and variable names follow camelCaseFormat).
What you are doing here is:
You are taking arguments, and overwriting those by class variables. Since you haven't initialized those (again, this is purely my assumption - because you haven't completely posted the code ), those variables are getting initialized by their default values (Object is null, int is 0 and so on).
So, you are actually assigning 0 and null to input parameters before printing it.
What Anayonkar is saying (correctly) is that your two assignments are in reverse order: you are assigning the class member TO the local variable, rather than assigning the local variable TO the class member. To prove the point, change the code to this:
By adding final to the input parameter list you prevent yourself from making the mistake you are making. What error do you get? Why?
Joined: Feb 22, 2012
thank you. it is just my silly mistakes. i am really sorry.