aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread output" Watch "Thread output" New topic
Author

Thread output

sumit kothalikar
Ranch Hand

Joined: Apr 15, 2010
Posts: 91

see the following code


and the output is

[I@42e816
[I@42e816
[I@42e816
[I@42e816
[I@42e816
[I@42e816
[I@42e816

Why the output is not
2
34
5
6
7
8
9

Is it because i have marked mt ref variable as final or is it because m1() method is synchronized.

Thanks & Regards
Sumit Kothalikar
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

In m1 method, you are displaying the array a in the loop not the loop variable x. Since a is a local array, there are no synchronization issues. Each call to the m1 method will have a separate copy of a array...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Is it because i have marked mt ref variable as final or is it because m1() method is synchronized.

None of those. Closely check what exactly you are printing inside the "System.out.." statement


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
sumit kothalikar
Ranch Hand

Joined: Apr 15, 2010
Posts: 91

thanks Vijitha


Vijitha Kumara wrote:
None of those. Closely check what exactly you are printing inside the "System.out.." statement


you are right i am printing array object reference.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Thread output