This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread output  RSS feed

 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • 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: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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: 3992
27
Chrome Fedora Hibernate
  • 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
  • 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
Boost this thread!