3:25 pm - Monday September 25, 2017

Collections Example program for frequency(Collection c, Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
@author:Candid
@discription:Collections Example program for frequency(Collection c, Object o)
**/
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Freq
{
   public static void main(String args[])
{
     List arrlist = new ArrayList();   //Create object arrlist
      arrlist.add("X");                           //add x in arrlist
      arrlist.add("Y");                           //add y in arrlist
      arrlist.add("Z");                           //add z in arrlist
      arrlist.add("G");                          //add G in arrlist
      arrlist.add("C");                          //add c in arrlist
      int freq = Collections.frequency(arrlist, "Z");  //To find freq()
      System.out.println("Frequency of 'Z' is: "+freq);//to print freq
}
}

Output:
Frequency of ‘Z’ is: 1

BACK

Filed in: Z-A All Java Codes

Comments are closed.