मैं 2 में जाना जाता BSTs के चौराहे से एक नया BST बनाने के लिए कोशिश कर रहा हूँ। मैं, intersect2 विधि पूर्णांक वह दूसरे मामले में एक NullPointerException हो रही लाइन में cur3.item.set_account_id (cur1.item.get_accountid () + cur2.item.get_accountid ());। मैं जब आप इसे आरंभ करने के बिना चर भिन्नता करने की कोशिश आप त्रुटि मिलती है, लेकिन मुझे लगता है कि मैं इसे आरंभ कर रहा हूँ? मैं बहुत पक्का नहीं हूँ। मैं मदद की सराहना करेंगे।
public static Bst<Customer> intersect(Bst<Customer> a, Bst<Customer> b){
return( intersect2(a.root, b.root));
}
public static Bst<Customer> intersect2(BTNode<Customer> cur1, BTNode<Customer> cur2){
Bst<Customer> result = new Bst<Customer>();
// 1. both empty -> true
if (cur1==null && cur2==null){
result=null;
}
// 2. both non-empty -> compare them
else if (cur1!=null && cur2!=null) {
BTNode<Customer> cur3 = new BTNode<Customer>();
cur3.item.set_account_id(cur1.item.get_accountid()+ cur2.item.get_accountid());
result.insert(cur3.item);
intersect2(cur1.left, cur2.left);
intersect2(cur1.right, cur2.right);
}
// 3. one empty, one not -> false
else if (cur1==null ||cur2==null){
BTNode<Customer> cur3 = new BTNode<Customer>();
cur3.item=null;
intersect2(cur1.left, cur2.left);
intersect2(cur1.right, cur2.right);
}
return result;
}
यहाँ समस्या की छवि है: 













