incompatible types: Node is not a functional interface











up vote
0
down vote

favorite












Using openjdk 10.0.2 2018-07-17



I got the following code. (It is a copy of this)



Using javasc to compile, I got this error. ListInter.java:80: error: incompatible types: Node is not a functional interface



// 1 class has all
class ListInter {

// like global var
static Node h1;
static Node h2;

// static class in class
static class Node {
// val
int val;
// next
Node next;

// constructor
Node(int v) {
// we don't call this, use straight
val = v;
// we don't call this, use straight
next = null;
}
}

Node getThatNode() {
// static h1, count
// no need this
int c1 = countNodeNum(h1);
// static h2, count
int c2 = countNodeNum(h2);
// diff
int diff;

// c1 list longer than c2
if (c1 > c2) {
// get diff
diff = c1 - c2;
return getJoinedNode(diff, h1, h2);
} else {
// c2 longer than c1
diff = c2 - c1;
return getJoinedNode(diff, h2, h1);
}
}

Node getJoinedNode(int diff, Node h1, Node h2) {
// consume
int i;
// point
Node curr1 = h1;
// point
Node curr2 = h2;

// consume all diff
for (i = 0; i < diff; i++) {
// to the end of list, in case
if (curr1 == null) {
return null;
}
curr1 = curr1.next;
}

while(curr1 != null && curr2 != null) {
if (curr1.val == curr2.val) {
return curr1;
}
curr1 = curr1.next;
curr2 = curr2.next;
}

return null;
}

int countNodeNum(Node node) {
// point
Node curr;
int num = 0;

curr = node;
while(curr != null) {
curr = curr->next;
num++;
}

return num;
}

// main
public static void main(String args) {
// itself
ListInter list = new ListInter();

list.h1 = new Node(3);
list.h1.next = new Node(6);
list.h1.next.next = new Node(15);
list.h1.next.next.next = new Node(15);
list.h1.next.next.next.next = new Node(30);

list.h2 = new Node(10);
list.h2.next = new Node(15);
list.h2.next.next = new Node(30);

System.out.println("The node of intersection is " + list.getThatNode());


}
}









share|improve this question


























    up vote
    0
    down vote

    favorite












    Using openjdk 10.0.2 2018-07-17



    I got the following code. (It is a copy of this)



    Using javasc to compile, I got this error. ListInter.java:80: error: incompatible types: Node is not a functional interface



    // 1 class has all
    class ListInter {

    // like global var
    static Node h1;
    static Node h2;

    // static class in class
    static class Node {
    // val
    int val;
    // next
    Node next;

    // constructor
    Node(int v) {
    // we don't call this, use straight
    val = v;
    // we don't call this, use straight
    next = null;
    }
    }

    Node getThatNode() {
    // static h1, count
    // no need this
    int c1 = countNodeNum(h1);
    // static h2, count
    int c2 = countNodeNum(h2);
    // diff
    int diff;

    // c1 list longer than c2
    if (c1 > c2) {
    // get diff
    diff = c1 - c2;
    return getJoinedNode(diff, h1, h2);
    } else {
    // c2 longer than c1
    diff = c2 - c1;
    return getJoinedNode(diff, h2, h1);
    }
    }

    Node getJoinedNode(int diff, Node h1, Node h2) {
    // consume
    int i;
    // point
    Node curr1 = h1;
    // point
    Node curr2 = h2;

    // consume all diff
    for (i = 0; i < diff; i++) {
    // to the end of list, in case
    if (curr1 == null) {
    return null;
    }
    curr1 = curr1.next;
    }

    while(curr1 != null && curr2 != null) {
    if (curr1.val == curr2.val) {
    return curr1;
    }
    curr1 = curr1.next;
    curr2 = curr2.next;
    }

    return null;
    }

    int countNodeNum(Node node) {
    // point
    Node curr;
    int num = 0;

    curr = node;
    while(curr != null) {
    curr = curr->next;
    num++;
    }

    return num;
    }

    // main
    public static void main(String args) {
    // itself
    ListInter list = new ListInter();

    list.h1 = new Node(3);
    list.h1.next = new Node(6);
    list.h1.next.next = new Node(15);
    list.h1.next.next.next = new Node(15);
    list.h1.next.next.next.next = new Node(30);

    list.h2 = new Node(10);
    list.h2.next = new Node(15);
    list.h2.next.next = new Node(30);

    System.out.println("The node of intersection is " + list.getThatNode());


    }
    }









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Using openjdk 10.0.2 2018-07-17



      I got the following code. (It is a copy of this)



      Using javasc to compile, I got this error. ListInter.java:80: error: incompatible types: Node is not a functional interface



      // 1 class has all
      class ListInter {

      // like global var
      static Node h1;
      static Node h2;

      // static class in class
      static class Node {
      // val
      int val;
      // next
      Node next;

      // constructor
      Node(int v) {
      // we don't call this, use straight
      val = v;
      // we don't call this, use straight
      next = null;
      }
      }

      Node getThatNode() {
      // static h1, count
      // no need this
      int c1 = countNodeNum(h1);
      // static h2, count
      int c2 = countNodeNum(h2);
      // diff
      int diff;

      // c1 list longer than c2
      if (c1 > c2) {
      // get diff
      diff = c1 - c2;
      return getJoinedNode(diff, h1, h2);
      } else {
      // c2 longer than c1
      diff = c2 - c1;
      return getJoinedNode(diff, h2, h1);
      }
      }

      Node getJoinedNode(int diff, Node h1, Node h2) {
      // consume
      int i;
      // point
      Node curr1 = h1;
      // point
      Node curr2 = h2;

      // consume all diff
      for (i = 0; i < diff; i++) {
      // to the end of list, in case
      if (curr1 == null) {
      return null;
      }
      curr1 = curr1.next;
      }

      while(curr1 != null && curr2 != null) {
      if (curr1.val == curr2.val) {
      return curr1;
      }
      curr1 = curr1.next;
      curr2 = curr2.next;
      }

      return null;
      }

      int countNodeNum(Node node) {
      // point
      Node curr;
      int num = 0;

      curr = node;
      while(curr != null) {
      curr = curr->next;
      num++;
      }

      return num;
      }

      // main
      public static void main(String args) {
      // itself
      ListInter list = new ListInter();

      list.h1 = new Node(3);
      list.h1.next = new Node(6);
      list.h1.next.next = new Node(15);
      list.h1.next.next.next = new Node(15);
      list.h1.next.next.next.next = new Node(30);

      list.h2 = new Node(10);
      list.h2.next = new Node(15);
      list.h2.next.next = new Node(30);

      System.out.println("The node of intersection is " + list.getThatNode());


      }
      }









      share|improve this question













      Using openjdk 10.0.2 2018-07-17



      I got the following code. (It is a copy of this)



      Using javasc to compile, I got this error. ListInter.java:80: error: incompatible types: Node is not a functional interface



      // 1 class has all
      class ListInter {

      // like global var
      static Node h1;
      static Node h2;

      // static class in class
      static class Node {
      // val
      int val;
      // next
      Node next;

      // constructor
      Node(int v) {
      // we don't call this, use straight
      val = v;
      // we don't call this, use straight
      next = null;
      }
      }

      Node getThatNode() {
      // static h1, count
      // no need this
      int c1 = countNodeNum(h1);
      // static h2, count
      int c2 = countNodeNum(h2);
      // diff
      int diff;

      // c1 list longer than c2
      if (c1 > c2) {
      // get diff
      diff = c1 - c2;
      return getJoinedNode(diff, h1, h2);
      } else {
      // c2 longer than c1
      diff = c2 - c1;
      return getJoinedNode(diff, h2, h1);
      }
      }

      Node getJoinedNode(int diff, Node h1, Node h2) {
      // consume
      int i;
      // point
      Node curr1 = h1;
      // point
      Node curr2 = h2;

      // consume all diff
      for (i = 0; i < diff; i++) {
      // to the end of list, in case
      if (curr1 == null) {
      return null;
      }
      curr1 = curr1.next;
      }

      while(curr1 != null && curr2 != null) {
      if (curr1.val == curr2.val) {
      return curr1;
      }
      curr1 = curr1.next;
      curr2 = curr2.next;
      }

      return null;
      }

      int countNodeNum(Node node) {
      // point
      Node curr;
      int num = 0;

      curr = node;
      while(curr != null) {
      curr = curr->next;
      num++;
      }

      return num;
      }

      // main
      public static void main(String args) {
      // itself
      ListInter list = new ListInter();

      list.h1 = new Node(3);
      list.h1.next = new Node(6);
      list.h1.next.next = new Node(15);
      list.h1.next.next.next = new Node(15);
      list.h1.next.next.next.next = new Node(30);

      list.h2 = new Node(10);
      list.h2.next = new Node(15);
      list.h2.next.next = new Node(30);

      System.out.println("The node of intersection is " + list.getThatNode());


      }
      }






      java






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 4:05









      kenpeter

      1,34361937




      1,34361937
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          change curr = curr->next to curr = curr.next (at line 80)






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245750%2fincompatible-types-node-is-not-a-functional-interface%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            change curr = curr->next to curr = curr.next (at line 80)






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              change curr = curr->next to curr = curr.next (at line 80)






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                change curr = curr->next to curr = curr.next (at line 80)






                share|improve this answer












                change curr = curr->next to curr = curr.next (at line 80)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 4:15









                Umer Farooq

                4751210




                4751210






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245750%2fincompatible-types-node-is-not-a-functional-interface%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python