Simple Problem..


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Simple Problem..

  1. #1
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279

    Simple Problem..

    Hello..
    I am quite new to Java and havent picked up on the little nuances it has.. I am getting an error "Cannot find Symbol" class BTNode..
    Do I need to import it or something, I do not understand why it cannot be found? Below are the classes I am trying to use..

    BTNode Class
    Code:
    public class BTNode{
        protected Object data;
        protected BTNode left,right;
    
        public BTNode(){
            data = null;
            left = right = null;
        }
        public BTNode(Object d){
            data = d;
            left = right = null;
        }
        public void setLeft(BTNode sleft){
            left = sleft;
        }
        public void setRight(BTNode sright){
            right = sright;
        }
        public void setData(Object sdata){
            data = sdata;
        }
        public BTNode getLeft(){
            return left;
        }
        public BTNode getRight(){
            return right;
        }
        public Object getData(){
            return data;
        }
    }
    Binary Tree abstract class
    Code:
    public abstract class BinaryTree{
        private BTNode root;
    
        protected BTNode getRoot(){
            return root;
        }
        protected void setRoot(BTNode r){
            root = r;
        }
        public BinaryTree(){
            setRoot(null);
        }
        public BinaryTree(Object o){
            setRoot(new BTNode(o));
        }
        public boolean isEmpty(){
            return getRoot() == null;
        }
        public Object getData(){
            if(!isEmpty())
                return getRoot().getData();
            return null;
        }
        public BTNode getLeft(){
            if(!isEmpty())
                return getRoot().getLeft();
            return null;
        }
        public BTNode getRight(){
            if(!isEmpty())
                return getRoot().getRight();
            return null;
        }
        public void setData(Object o){
            if(!isEmpty())
                getRoot().setData(o);
        }
        public void insertLeft(BTNode p,Object o){
            if((p != null) && (p.getLeft() == null))
                p.setLeft(new BTNode(o));
        }
        public void insertRight(BTNode p,Object o){
            if((p != null) && (p.getRight() == null))
                p.setRight(new BTNode(o));
        }
        public void print(int mode){
            if(mode == 1) pretrav();
            else if(mode == 2) intrav();
            else if(mode == 3) postrav();
        }
        public void printPreOrder(){
            printPreOrder(getRoot());
        }
        protected void printPreOrder(BTNode p){
            if(p == null)
                return;
            System.out.print(p.getData()+" ");
            printPreOrder(p.getLeft());
            printPreOrder(p.getRight());
        }
        public void printInOrder(){
            printInOrder(getRoot());
        }
        protected void printInOrder(BTNode p){
            if(p == null)
                return;
            printInOrcder(p.getLeft());
            System.out.print(p.getData()+" ");
            printInOrder(p.getRight());
        }
        public void printPostOrder(){
            printPostOrder(getRoot());
        }
        protected void printPostOrder(BTNode p){
            if(p == null)
                return;
            printPostOrder(p.getLeft());
            printPostOrder(p.getRight());
            System.out.print(p.getData()+" ");
        }
    }
    Any help would be appreciated..
    Thankyou

  2. #2
    Join Date
    Jul 2005
    Location
    Antwerp - Belgium
    Posts
    29

    late answer

    Sorry for the late answer...
    Normally you do not have to import classes you have written yourself as long as you are using them in the same folder as other classes which are referring to the first class.
    Just to be sure : are you still having this problem, since it's a while that you've made this thread ?
    And how do you compile : from within an IDE like Eclipse or from a DOS box ?

  3. #3
    Join Date
    Aug 2005
    Posts
    17
    Do any of those classes have a package statement at the start? Are the two classes in different directories? You should check where the .class files are being stored.

    In summary, comment out any package statements (for now) and comment any imports for those packages (for now). Put all the files in the same directory. Try again.

    You could compile from DOS by going to the directory of the .java files and typing

    Code:
    javac *.java
    For more help, www.NeedProgrammingHelp.com

Similar Threads

  1. Replies: 0
    Last Post: 07-05-2005, 11:07 PM
  2. Simple SQL Parameter problem
    By Eric in forum Database
    Replies: 1
    Last Post: 11-10-2000, 02:05 AM
  3. typical problem, pls help
    By SATISH in forum Java
    Replies: 1
    Last Post: 09-29-2000, 09:33 AM
  4. Replies: 0
    Last Post: 06-23-2000, 02:17 PM
  5. Simple report problem
    By Gary Thompson in forum authorevents.kurata
    Replies: 1
    Last Post: 04-20-2000, 08:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center