Java List Interface Methods | Java List Interface (Java Tutorial)

Hi friends, this is Rakesh. Now we are going to see about the list interface in detail, So this interface has name that suggests it is an interface, So The interface, the basic difference of interface is it contains some abstract methods.

It contains only the method declarations.

So the method definitions need to be in the implemented classes.

Similarly, list interface contains only the abstract methods.

The actual implementations would be available in the implement of classes Like array ways linked ways like that.

So then it extends a collection interface.

So the abstract methods that are present in the collection interface also moves to the list interface.

The basic definition of the list is, it can contain to duplicate values, For example, 1, 2, 1, 3.

So here 1 1 repeats two times, So it can contain duplicate values.

So you can access the values by the position, So you can access 1 by you. Can access object using position? You can get the values using 0, 1, 2, 3 and etc.

There is the basic definition of list interface.

We’ll talk about more about the array list linked list in upcoming videos.

These are the abstract methods that are present in the list.

Interface.

The first one is public void.

Add int index Object o, So what it does try to convey is It will try to add the object in this index position, For example, it will send 1 and 5 data.

5 object means they try to get here.

It will try to add that object here and it will try to shift the cells It will try to move.

This 2 object here. 1 object here and 3 object here, So tries to shift the remaining objects in the other.

So next one public, boolean, addAll int index Collection c.

So here the elements that are present in the collection c would be added, with the would be added from that index position and then public Object get int index.

If suppose, if we have sent the 1 as a value means, it will try to return the object for this get object.

If suppose we’ll talk about this Public int lastIndexOf Object o.

So before that we will see this public int indexOf Object.

0.

If suppose, if you are sending 1 In suppose, if match is 1 or many times, it returns, the first index position, So here 1 Zero in the index, So it returns.

This object.

Public int lastIndexOf Object o. This is opposite of this method.

It return the last index.

So, if suppose, if data is repeated in the list means it will try to return the last index here, 1 repeated twice, so it returns this position.

2.

We’ll talk more about this in the upcoming videos and then of the public object remove int index.

If we suppose, if suppose you set 1 as the argument value, then you will try to find this.

If you try to remove this data and you’ll – try to slip the cells from 2nd to 1 3rd to 2.

Like that And then public list subList int start int end.

If we suppose, if we set 1 and 2, it will try to return the elements return.

The sub list from that start to end position 1. 2.

So it will try to return this sub list.

So thanks for watching this video At the end of this video, you’ll see the channel icon here.

Please click on that for subscribing the channel .

As found on YouTube

Automating your affiliate marketing efforts


Discover more from Automatically generating your monthly income?

Subscribe to get the latest posts sent to your email.

Author: yousekbastellinek

Hello, my name is Jose Amorós first of all I wish you a warm welcome to my blog. It will be a pleasure to share with all of you information about my career and thus evaluate knowledge that will be beneficial for both of us. Now that you know me, I give you a warm welcome and thank you for visiting my profile. Do not hesitate to contact me. I will answer all your questions and doubts that you have, greetings and welcome!

Leave a Reply