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




get( ) FUNCTION


The get( ) Function is used get a 'Value' associated with a 'Key' in a Dictionary.


Example :


x = {
    5 : "Is a Number", 
    "John": "Is a Name", 
    "Python": "Is a Language"
}
y = x.get("John")
print(y)


Output :



  Is a Name

So, in the above code we have created a 'Dictionary' using braces '{ }' and 'Key' and 'Value' pairs.


x = {
    5 : "Is a Number", 
    "John": "Is a Name", 
    "Python": "Is a Language"
}

And initialised to the variable 'x'.


java_Collections

Then we have used the 'get( )' Function to get the 'Value' associated with the 'Key', 'John'.


y = x.get("John")

The 'Value' associated with the 'Key', 'John' is 'Is a Name'. And that is assigned to 'y'.


java_Collections