File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread output

 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic