На операторе return выдается ошибка - несовместимые типы. Не могу понять, что с чем не совместимо получается в программе. Разъясните пожалуйста, что я не так сделал.
Код программы:
Код | package btree; import java.io.*; public class BinaryTree { public Node root; public BinaryTree()
{ root = null; }
public void insert(int data, String name, String surname, String course, String ticket, String army){
Node n = new Node(data, name, surname, course, ticket, army); if (root == null){ root = n; } else { Node current = root; Node parent; while(true) { parent = current; if(data < current.data){ current = current.left; } if (current == null) { parent.left = n; return; } else { current = current.right; if(current == null){ parent.right = n; return;
} } } } } public BinaryTree find(int key){ Node current = root;
while(current.data != key){ if(key < current.data){ current = current.left; } else { current = current.right; }
if(current == null) { return null; }
} return current; //ошибку выдает на этой строке }
} class bTreeApp { public static void main(String[] args ) { BinaryTree theTree = new BinaryTree(); theTree.insert(1, "vasa", "pupkin", "3", "456987", "Yes"); theTree.insert(2, "ivan", "ivanov", "2", "789898", "No"); theTree.insert(4, "dima", "vengel", "3", "7896546", "No"); } }
class Node { Node left; Node right; int data; String name; String surname; String course; String ticket; String army; public Node(int data, String name, String surname, String course, String ticket, String army){ this.data = data; this.name = name; this.surname = surname; this.course = course; this.ticket = ticket; this.army = army; } }
|
|