Win a copy of Murach's Python Programming this week in the Jython/Python 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: 9608
36
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: 3973
24
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.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!