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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:11:16+00:00 2026-06-11T17:11:16+00:00

Using eclipse 4.2 with Java 7 and trying to implement the following method of

  • 0

Using eclipse 4.2 with Java 7 and trying to implement the following method of the List interface i got a warning.

public <T> T[] toArray(T[] a) {
    return a;

}

The warning says :

The type parameter T is hiding the type T

screenshot

Why ? How can i get rid of it ?

  • 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-11T17:11:17+00:00Added an answer on June 11, 2026 at 5:11 pm

    The List interface is also generic. Make sure that you are not also using T for the generic type in your class. Note that in http://docs.oracle.com/javase/6/docs/api/java/util/List.html, they use “E” for the class generic parameter and “T” for the toArray() generic parameter. This prevents the overlap.

    public class MyList<T> implements List<T> {
    
    // V1 (compiler warning)
    public <T> T[] toArray(T[] array) {
        // in this method T refers to the generic parameter of the generic method
        // rather than to the generic parameter of the class. Thus we get a warning.
        T variable = null; // refers to the element type of the array, which may not be the element type of MyList
    } 
    
    // V2 (no warning)
    public <T2> T2[] toArray(T2[] array) {
        T variable = null; // refers to the element type of MyList
        T2 variable2 = null; // refers to the element type of the array
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a new File in Eclipse using the following Java
I am trying to create my first GUI application using (Java + Eclipse +
I'm using Java 1.6 , Eclipse , Windows 7. I'm trying to run commands
I'm using Eclipse to code Java (for Android) and I'm trying to debug the
I am trying to implement Riot CMS to my Spring-java web application using http://www.riotfamily.org/docs/quickstart.html
Umm, I've been using Eclipse for Java development and I am trying to use
I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I'm trying
I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I'm trying
I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I'm trying
I'm trying to learn to use xml in Java (Android platform, using Eclipse and

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.