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

  • SEARCH
  • Home
  • 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 8697311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:29:39+00:00 2026-06-13T01:29:39+00:00

I am asked to convert a program to use generic types in my array.

  • 0

I am asked to convert a program to use generic types in my array.

I have no idea where to start. I tried to convert the array to generic but I keep getting problems.

I tried to just convert the array to generic one by using queArray = (T[]) (new Comparable[maxSize]); but after I modified all variables to suppose to use generic types I keep getting errors.

What do I have to change here?

  • 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-06-13T01:29:40+00:00Added an answer on June 13, 2026 at 1:29 am

    You want to declare that T must implement Comparable. This allows you to explicitly state that the PriorityQ can only support classes which can be compared for ordering. This is done like so:

    class PriorityQ<T extends Comparable<T>>
    

    Now queArray should be newed as an array of T since the PriorityQ is ordering instances of type T:

    queArray = new T[maxSize];  
    

    Lastly, use the Comparable.compareTo method for your comparisons:

    if( item .compareTo(queArray[j]) > 0 )      // if new item larger,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've asked about strtolower function. But when using foreign characters it doesn't convert them
I have been asked to convert an entire site that is currently using wordpress
I am trying to convert a Haskell program to a Haskell GUI program, but
I have asked this question before and used the soln but for some reason
I asked a similair question earilier, but it was not generic enough, so here's
I have been asked to convert some Lotus 123 wk4 files with macros to
I have been asked to convert a legacy app containing some crystal reports from
I need to convert image to Byte array as I have to upload to
How do I convert an array of char to a string? I have a
I have asked a similar question elsewhere but perhaps I did not ask it

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.