Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




append( ) FUNCTION


The 'append( )' Function is used to add a new element at the end of the List.


Let us say, we have a List that contains three names, 'Mohan', 'Kriti' and 'Salim'. And we want to insert a new name 'Mika' at the end of the List.


Example :


x = ["Mohan", "Kriti", "Salim"]
x.append("Mika")
print(x)     


Output :



  ['Mohan', 'Kriti', 'Salim', 'Mika']

So, in the above code we have created a 'List'and initialised to the variable 'x'.


x = ["Mohan", "Kriti", "Salim"]

Below is how the values are positioned in the List,


java_Collections

Next, we have used the 'append( )' function to add the new name 'Mika' at the end of the List.


x.append("Mika")

java_Collections

And we get the below output,


['Mohan', 'Kriti', 'Salim', 'Mika']