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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:46:07+00:00 2026-06-14T05:46:07+00:00

In my study book, there’s this example: import java.util.*; public class RentalGeneric<T> { private

  • 0

In my study book, there’s this example:

import java.util.*;
public class RentalGeneric<T> {

  private List<T> rentalPool;

  private int maxNum;
  public RentalGeneric(int maxNum, List<T> rentalPool) {

  this.maxNum = maxNum;
  this.rentalPool = rentalPool;
}
public T getRental() {
  return rentalPool.get(0);
}
  public void returnRental(T returnedThing) {
    rentalPool.add(returnedThing);
  }
}

I find it strange that it compiles, since there is no definition of Class<T>. What is the story about this? It says in my book that T is for the type parameter but how do I know when to use 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-14T05:46:09+00:00Added an answer on June 14, 2026 at 5:46 am

    You could use it to rent cars, bikes …
    You could use it directly like this:

    RentalGeneric<Car> carRental = new RentalGeneric<Car>(10, aList);
    

    Then when you’ll do getRental it’ll return you a Carobject.
    And you’ll be able to put back a Car with returnRental(aCar);

    Or you could create a CarRental class extending RentalGeneric<Car>.

    Same thing goes for whatever object you would like to rent.

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

Sidebar

Related Questions

I'm reading Sybex Complete Java 2 Certification Study Guide April 2005 (ISBN0782144195). This book
package org.study.algos; public class Study { public static void main(String[] args) { A a
I study this code from some book: #include <pthread.h> #include <stdio.h> /* Parameters to
link text This is a link from a digital book library.There are forward and
I study iOS SDK using this book and in 4 Chapter, when it tells
I'm reading this book and there is a chapter about prototypes with this hard
I study GoF Design Patterns book and have Martin Fowler's PoEAA book in list.
I'm almost finished with the book Head First Java. The reason I'm studying this
I'm looking for an exhaustive, university-level book or guide to study in order to
I'm preparing the SCJP exam with the almost official study book ("SCJP Sun Certified

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.