Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Print out object that is in a tree

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Thanked 0 Times in 0 Posts

    Default Print out object that is in a tree

    I am trying to print out the object in a tree. I have a toString method defined for the object. However, I get this error:

    I get a classCastException

    Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LPriorityQueueNode;
    at PriorityQueue.printPriorityQueue(PriorityQueue.jav a:49)
    at driver.main(driver.java:63)

    System.out.println( tree[0].getElement());

  2. #2
    Junior Member
    Join Date
    Mar 2010
    Thanked 1 Time in 1 Post

    Default Re: Print out object that is in a tree

    I think it returns a Node object

    getElementName() or getElementValue()

    to get the name n value of node,I m not sure weather it works or not


Similar Threads

  1. 500 Ways to Print 1 to 10
    By Freaky Chris in forum The Cafe
    Replies: 132
    Last Post: August 1st, 2014, 06:47 AM
  2. Data Structures(Binary Search Tree to AVL Tree)ASAP
    By jfAdik in forum Algorithms & Recursion
    Replies: 2
    Last Post: April 5th, 2010, 03:58 AM
  3. print space
    By brainTuner in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 1st, 2010, 06:09 PM
  4. Can someone please tell me why my code doesn't print out anything?
    By deeerek in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 6th, 2010, 08:35 AM
  5. print hex decimal value
    By ran830421 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 25th, 2009, 07:23 PM