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

The Archive Base Latest Questions

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

this morning I came across this code, and I have absolutely no idea what

  • 0

this morning I came across this code, and I have absolutely no idea what that means. Can anyone explain me what do these <T> represent? For example:

public class MyClass<T>
...

some bits of code then 

private Something<T> so;

private OtherThing<T> to;

private Class<T> c;

Thank you

  • 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-14T16:55:20+00:00Added an answer on May 14, 2026 at 4:55 pm

    You have bumped into “generics”. They are explained very nicely in this guide.

    In short, they allow you to specify what type that a storage-class, such as a List or Set contains. If you write Set<String>, you have stated that this set must only contain Strings, and will get a compilation error if you try to put something else in there:

    Set<String> stringSet = new HashSet<String>();
    stringSet.add("hello"); //ok.
    stringSet.add(3);
          ^^^^^^^^^^^ //does not compile
    

    Furthermore, another useful example of what generics can do is that they allow you to more closely specify an abstract class:

    public abstract class AbstClass<T extends Variable> {
    

    In this way, the extending classes does not have to extend Variable, but they need to extend a class that extends Variable.

    Accordingly, a method that handles an AbstClass can be defined like this:

    public void doThing(AbstClass<?> abstExtension) {
    

    where ? is a wildcard that means “all classes that extend AbstClass with some Variable“.

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

Sidebar

Related Questions

So I came across some code this morning that looked like this: try {
Whilst working on some generally horrible Javascript code this morning, I came across the
I came across a bug in some VB6 code this morning which wasn't evaluating
I came across this strange looking declaration in some code early this morning (before
This morning we found an old chunk of code that was causing a library
I was doing some reading on REST this morning and I came across the
Good Morning. Came across code implemented by someone else and I'm not understanding how
Woke up this morning with a page that our cluster was down. It came
I have a Java project that is using Cucumber for BDD. This morning the
I came in this morning, fired up my app in the same way as

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.