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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:22:22+00:00 2026-06-04T23:22:22+00:00

I finished learning Generics and I didn’t find it easy. However , I did

  • 0

I finished learning Generics and I didn’t find it easy. However , I did understand it. Here is what I understood. I want you to correct me where I am wrong and answer a few questions 🙂 .

public class LinkedList<T> {
//class definition
}
  • This means that LinkedList<> is a class that will accept objects of classes and also interfaces.
  • public class LinkedList<T extends Object> {
    //class definition
    }
    
  • This means that LinkedList<> is a class that will accept objects of those classes only that extend Object class. Basically, all classes. In case of a raw type, T will be replaced by Object
  • public class LinkedList<T extends Object & java.lang.Serializable> {
    //class definition
    }  
    
  • This means that LinkedList<> is a class that accepts objects of all those classes that implement Serializable interface. If an object of user defined class has to be included in the list then the user defined class must implement Serializable.
  • public class LinkedList<T> implements Iterable<T> {
    //class definition
    }  
    
  • This means that the LinkedList<> class can be used with a collection-based for loop. It must overload iterator() method and should have an inner class that implements Itarator<T> and overloads hasNext(), next() and remove()
  • Questions
    1. Please explain the meaning of this in simple words and with an example, if possible:
    public class BinaryTree<T extends Comparable<? super T>> what replaces the ?
    2. I want to write the above mentioned LinkedList<> class to a file using the writeObject() method. so I declare it as

    public class LinkedList<T extends Object> implements Serializable {
         //methods and data members      
    private class Node implements Serializable { //inner class
                      T object;
                      Node next;
               }
        }
    

    Does the inner class have to implement Serializable as well?

    • 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-04T23:22:24+00:00Added an answer on June 4, 2026 at 11:22 pm

      About your four first points:

      1. A list that is is supposed to contain instances of T (including classes that extend T).
      2. Actually identical to the first one, as all classes extend Object.
      3. A list that can only contain objects that are Serializable (same as class LinkedList<T extends Serializable> { ... })
      4. An iterable list of T, so yeah, it can be used in enhanced loops.

      Worth noting, when we say “a list that can only contain objects of the specified type”, we should say “should” instead of “can”. Unless you pass Class<?> objects around, Java (runtime) will not check the values passed in actually comply, only the compiler will, and only based on the visible static type, which could’ve been manually changed (that’d issue a warning).

      About the questions:

      1. It represents a BinaryTree that contains objects that are Comparable to any object of the same class as T or any of its supertypes (Object is one supertype of all classes, essentially all classes that T extends and all interfaces it implements).
      2. If you want to serialize the object using writeObject, then all non-transient (i.e. that you cannot rebuild based on other data) instance fields of that object need to be Serializable as well, or writeObject will ignore them. Your code extract isn’t quite sufficient to tell whether Node needs to be Serializable or not, but it probably needs to given the general idea of the List example.
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I just finished learning assembly language. But I couldn't understand what could I implement
    Already finished implementing the player. I want to implement the progress bar. But I
    I finished learning the Big Nerd Ranch Guide to iPhone programming but now I
    I am learning(just finished) C+Algorithms and am a newbie. I wanted to know if
    Still learning a lot.. But basically finally finished my website, but now I'm failing
    I finished some of the steps in http://framework.zend.com/manual/en/learning.quickstart.create-project.html and got it to work to
    In my learning I have always learnt and understood callbacks in jQuery like this:
    I am learning custom controls and just finished my first one. The problem is
    I am learning spring mvc and hibernate. i have just finished simple site with
    XNA noob here, learning every day. I just worked out how to composite multiple

    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.