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

doubt!!!

 
sriram gupta
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
what will be the output of the following and if u can tell me why it will be very helpful...
class{
int i=valueofi();
int j=10;
int valueofi(){return j;}
}

// the value of i after this is 0 but i couldn't understand why???
 
swati bannore
Ranch Hand
Posts: 201
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Same code was recently discussed here.
The method is called before iniitialization of variable j to value 10. So method returns the default value of int variable j i.e. 0.
Thanx.
 
sriram gupta
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx swati....
it is clear now....
 
Muhammad Farooq
Ranch Hand
Posts: 356
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just try this
class{
int j=10;
int i=valueofi();
int valueofi(){return j;}
}
HTH
--Farooq
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic