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 1094231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:56:39+00:00 2026-05-16T23:56:39+00:00

I want to change the return type of this method to a class (

  • 0

I want to change the return type of this method to a class (ReturnContainer) that can hold the tupelo object in addition to another return value that I need to send back to the calling method.

I’ve never worked with this <T> concept in Java before so I don’t how to reconfigure this method to work the way I need it to.

public static <T extends LocationCapable> List<T> test(Class<T> incomingClass)
{
    List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
    return tupelo;
}

When I try to change the code to the listing below, I get the error:

T cannot be resolved to a type

How can I have a return type of ReturnContainer but still allow the incomingClass to be a dynamic type?

public static ReturnContainer test(Class<T> incomingClass)
{
            List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
            ReturnContainer rc = new ReturnContainer(tupelo, incomingClass);
    return rc;
}
  • 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-16T23:56:39+00:00Added an answer on May 16, 2026 at 11:56 pm

    You’re missing the type parameter:

    public static <T> ReturnContainer test(Class<T> incomingClass)
    {
        List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
        ReturnContainer rc = new ReturnContainer(tupelo, incomingClass);
        return rc;
    }
    

    To my eyes, though, this looks weird. Shouldn’t ReturnContainer have a type parameter, too? In which case, you’d have

    public static <T> ReturnContainer<T> test(Class<T> incomingClass)
    {
        List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
        ReturnContainer rc = new ReturnContainer<T>(tupelo, incomingClass);
        return rc;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have many div's with the same background image and i want change this
I want to change some properties of a LINQ query result object without creating
I want to change the behaviour of the editable ComboBox. This is the behaviour
I want to change the view size for iPhone 3.0, but I find that
I want to change the toggle function so that it changes the text of
I'm binding to a method using an ObjectDataProvider. The class which exposes this method
I have a method in my code which must have a void return type
Suppose I have a class TestCollection which is used to hold objects of type
I'm creating a method that will use CastleWindsor to try to resolve a type,
I have the following generic method inside my class that works as a repository

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.