Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dart program that removes all occurrences of a specified element from a list.
- void main()
- {
- int a=2;
- List<int> nums =[1,2,2,3,4,2];
- print("The number of times ${a} is repeated is ${remEle(a,nums)}");
- }
- remEle(int a1, List<int> nums1)
- {
- int count=0;
- for(int i=0;i<nums1.length;i++)
- {
- if(nums1[i]==a1)
- {
- count++;
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement