Advertisement
Hiteshw11

Find the Key for a Specific Value

Nov 19th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.23 KB | Source Code | 0 0
  1. // Find the Key for a Specific Value
  2.  
  3. void main() {
  4.   Map<String,int> ages ={'John':25,'Jake':30,'Ray':22};
  5.   int targetAge=30;
  6.  
  7.   for(MapEntry c in ages.entries)
  8.   {
  9.     if(c.value==targetAge)
  10.       print(c.key);
  11.    }
  12.  
  13. }
Tags: dart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement