Here I am trying to practice making binary trees so that I can do different operations with them.
import java.util.*;
import java.lang.*;
public class Main {
public static void main(String[] args) {
}
}
//Building Binary Trees
class bTree {
static class Node { //remember to initilize a root
String value;
Node left, right;
Node(String value, Node left, Node right) {
this.value = value;
this.left = left;
this.right = right;
}
Node(String value) //THIS IS A SIBLING CONSTRUCTOR
{
this(value, null, null);
}
Node root = new Node("ROOT");
Node lefty = new Node("LEFT0");
Node righty = new Node("RIGHT0");
root.left = lefty;
root.right = righty;
}
Node root = null;
}
Why am I getting the error: Identifier expected at the root.left and root.right assignment?
Thanks!