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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:08:01+00:00 2026-06-17T01:08:01+00:00

Possible Duplicate: How list methods works in java List is an interface in java.

  • 0

Possible Duplicate:
How list methods works in java

List is an interface in java. And it has some methods. Generally an interface is a specification of method prototypes. i.e. interface consist of methods signature only no implementation will be there for that methods in interface.

I have a doubt that how the methods of List interface work if they don’t have any implementation inside the interface.

Suppose I have a class Book which has name property, setter,getter methods. and I have another class getBooks like this.

public class GetBooks{
List<Book> list;
public List<Book> getBooks(){
return list;
}
//setter method..
}

I am sending books into the set method at runtime through some other class.

I have another class UseBooks like this.

public class UseBooks{
.....
....
List<Book> list = new GetBooks().getBooks();
list.add(new Book("aaa"));
}

My question is how add method is adding books even it is in interface List because my getBooks() returning List interface not Arraylist or some other implementation class.

  • 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-17T01:08:02+00:00Added an answer on June 17, 2026 at 1:08 am
    List<Book> list
    

    Here list is a reference to an object, not an object itself. When you call interface methods on this reference, you are actually calling the overridden methods of some concrete class that this reference points to.

    To illustrate

    List<Book> list = new List<Book>(); //Illegal
    List<Book> list = new ArrayList<Book>(); //legal ArrayList is a concrete implementation of list.
    

    That is the power of interfaces, I can do stuff with this reference without worrying about how it works or how it is implemented.

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

Sidebar

Related Questions

Possible Duplicate: Some built-in to pad a list in python I have a method
Possible Duplicate: C++ Vector Pointers to Objects Does std::list::remove method call destructor of each
Possible Duplicate: How to convert List<Integer> to int[] in Java? I have an ArrayList
Possible Duplicate: PHP Built-in Method to Get Array Values Given a List of Keys
Possible Duplicate: List all files from a directory recursively with Java How can i
Possible Duplicate: Is List<Dog> a subclass of List<Animal>? Why aren't Java's generics implicitly polymorphic?
Possible Duplicate: Does std::list::remove method call destructor of each removed element? I have a
Possible Duplicate: scala: adding a method to List? I struggle to formulate what I'm
Possible Duplicate: Why is there not a ForEach extension method on the IEnumerable interface?
Possible Duplicate: Method has the same erasure as another method in type In one

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.