• Post Reply Bookmark Topic Watch Topic
  • New Topic

CallBack Function In Java  RSS feed

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks
Chandra
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- Define an interface that contains the method String getData(String s1, String s2, String s3) (call it Callback, for exmple)
- Make class A implement that interface
- Make the updateList method in class B take a variable of the interface type as an argument
- In the updateList method of class B call the getData method on that argument variable
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra shekar M wrote:Thanks
Chandra

Erm, and your question is...?

Winston
 
Chandra shekar M
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks,

Yes, you are right i have already done this part what you are saying. But how Does class B passin the required arguments for getData().

Thanks

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra shekar M wrote:But how Does class B passin the required arguments for getData().

What do you mean exactly? How the updateList method of class B gets the values for s1, s2, s3 that it should pass to the getData() method? It must have some way to get these; maybe you should add them as arguments to the updateList method of class B, so that it can pass them to getData().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!