Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7446579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:20:55+00:00 2026-05-29T12:20:55+00:00

Alright, so I’ve been trying to implement a simple binary search tree that uses

  • 0

Alright, so I’ve been trying to implement a simple binary search tree that uses a comparable data type by default.

Ignoring all my other methods in the class, this is the general setup I have which I think is pretty standard:

public class BSTNode<E extends Comparable<? super E>>{
     E data;
     BSTNode<E> left;
     BSTNode<E> right;
     //and I'm trying to define a static method(inside of the class) like this:
     public static <E> String displayAscending(BSTNode<E> node){} 
}

But the compiler isn’t liking it. Now, I’m kind of new to generic types so I’ll explain my understanding of what this does and that might help you in figuring out what’s wrong with my thinking.

E extends Comparable
So basically an object E that is an extension of Comparable. Comparable having an element that is an ancestor of E, which essentially is an abstract way of saying E can be compared with its other elements using the Comparable interface.

Then in my static method I’m trying to pass the BSTNode recursively. I can’t seem to wrap my head around why it’s not working. I know If I pass BSTNode<?> it works fine, but that seems dangerous. If someone could explain to me WHY this isn’t working I could try and find another solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:20:58+00:00Added an answer on May 29, 2026 at 12:20 pm

    try this

    public static <E extends Comparable<? super E>> String displayAscending(BSTNode<E> node)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I have some data that I need to assign an int type identifier
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright, I'm trying to read a comma delimited file and then put that into
Alright, I am trying to accomplish this: When a user clicks a button that
Alright, currently I have my SWF hitting a php file that will go and
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright, after doing a ton of research and trying almost every managed CPP Redist
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright so this is a bizarre cross platform thing that I'm experiencing with text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.