简体   繁体   中英

I get “<identifier> expected” For my code and i don't understand why my code isn't working

The issue is that it says Identifier Expected but i don't know whats expected

public class TTester 
    { 
    public static void main(String args[]) // main
    { 
    //the first integer in the tree is used to create the object 
       BST bstObj = new BST(50); // creating the object
       bstObj.addNode(56); 
       bstObj.addNode(52);     
       bstObj.addNode(25); //The numbers added
       bstObj.addNode(74); 
       bstObj.addNode(54); 
    } 
        bstObj.traverseAndPrint(bstObj.rootNode); // wanting to print the program
    } 

In JAVA all executable statement must be inside a method/block only. Your following statement is not part of any method/block:

bstObj.traverseAndPrint(bstObj.rootNode); 

Try moving it inside the main method and test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM