I have this program that I am working on that I am trying to insert user entered integers till a "-1" is detected and it will stop inserting the integers into the Tree and print it out inOrder.

I am geting 2 errors:

File: S:\makeup1.java [line: 9]
Error: S:\makeup1.java:9: cannot find symbol
symbol : class Tree
location: class makeup1

File: S:\makeup1.java [line: 9]
Error: S:\makeup1.java:9: cannot find symbol
symbol : class Tree
location: class makeup1

import java.util.Scanner;
import java.io.*;

public class makeup1{
  
    public static void main(String [] args){
    
    int n;
    Tree t = new Tree();
    Scanner scanner = new Scanner(System.in);
    
    while(n!=-1){
      System.out.println("input integer into tree: ");
      n = scanner.nextInt();
      insert(t,n);
    }
   
  }
   public static class tree{
    public int value;
    public tree right;
    public tree left;
    public tree(int V, tree L, tree R){
      {
        value = V;
        left = L;
        right = R;
      }
    }
  }
   
   public static tree insert(tree t, int i){
     if(t==null){
      return null; 
     }
     if(t.left!=null){
       insert(t.left, i);
     }
     else if(t.right!=null){
       insert(t.right, i);
     }
   }
   public static tree treesort(tree t){
     if(t==null){
       return null;
     }
     if(!(t.left==null)){
       return t.left;
     }
     return t.right;
   }

}

Can anyone help me out?

Recommended Answers

All 2 Replies

Hello.
The compiler tells you that it doesn't understand what is Tree[/]. To fix the problem you should either add import for Tree data type, or declare this data type in your makeup1 class.

You have Tree t = new Tree(); but the class you defined is "tree" in lower case. Change the line to lower case "tree", or change the class to upper case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.