Results 1 to 3 of 3

Thread: call chaining

  1. #1
    vlad is offline Member
    Join Date
    May 2010
    Location
    Colorado
    Posts
    6
    Rep Power
    0

    Question call chaining

    What is the problem here..? Why doesn't this work?

    public class Foo2 {
    String a = "he";

    String test1(){return a + "ll";}
    String test2(){return "oo";}
    String test3(){return "ow";}
    }
    public class Foo{

    public static void main(String[] args) {

    Foo2 foo = new Foo2();

    String a = foo.test1().test2().test3();
    System.out.println(a);

    }

    }

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Because test2 and test3 are not methods of String, and a String is what test1 and test2 return.

  3. #3
    vlad is offline Member
    Join Date
    May 2010
    Location
    Colorado
    Posts
    6
    Rep Power
    0

    Default

    Thanks msijade! I am just trying to test some method chaining ideas... So the first test1() and second test2() both return a reference to a String and thats why its not working... So how would you convert it so it would return Foo2 type instead..? thnx! - vlad

Similar Threads

  1. servlet chaining
    By bbq in forum Java Servlet
    Replies: 2
    Last Post: 01-23-2012, 09:02 AM
  2. call a JSP method
    By sauravsinha in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 09-26-2011, 04:19 PM
  3. not able to call the ejb
    By deepak9976 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 08-07-2009, 10:12 AM
  4. how to call dll from java ??
    By Omarero in forum New To Java
    Replies: 3
    Last Post: 11-13-2008, 05:14 AM
  5. Hash table with separate chaining
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •