finding name in the array using java
import java.util.*;
class FindName { public static void main(String[] arg) { String []args={"Dave", "Ann", "George", "Sam", "Ted", "Gag", "Saj", "Agati", "Mary", "Sam", "Ayan", "Dev", "Kity", "Meery", "Smith", "Johnson", "Bill", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas","Jackson"}; int len=args.length; int count=0; System.out.println("Number of names are "+len); for(int i=0;i<len;i++) for(int j=0;j<len;j++) if(i!=j) if(args[i].equals(args[j])) { count=count+1; System.out.println("Same Name availabale "+args[i]+" at the position of "+j); } System.out.println("Occured " +count+" times"); } }</len;j++) </len;i++) OutPut: |
0 comments:
Post a Comment