• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help to understand whats the wrong with my guess  RSS feed

 
rayan alex
Ranch Hand
Posts: 33
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please try to understand why this program produce 100 200 as output. I was expecting out put as 100 200 30 40
 
Wayan Saryada
Ranch Hand
Posts: 119
Hibernate Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I suppose you are expecting that the constructor of MyClass class got called. But actually you are not defining a constructor in MyClass. A constructor doesn't have a return type in its definition.
 
Varun Nambuthiri
Ranch Hand
Posts: 76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Rayan as Wayan said . A constructor should only contain the access modifier and not the return type .


 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always indent your code correctly. You are making it hard for yourself because unindented code is difficult to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!