Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock quesiton :output is confusing

 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

output :82
why it is not coming 92?
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primitives are passed to methods as a values - this is the first point.
The second one is that you are shadowing the instance variable "squares" with method parameter named the same "squares".

Try changing the method argument from "squares" to "squares2" and see what happens:



 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pedro Kowalski wrote:
The second one is that you are shadowing the instance variable "squares" with method parameter named the same "squares".

yeah got it,
thanks pedro.
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem mate :-) Glad it helped!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic