题解 | #小乐乐查找数字#
小乐乐查找数字
http://www.nowcoder.com/practice/4c49a3a1559141f7a080a48c98cca4cb
import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(); for(int i=0; i<n; i++){ list.add(sc.nextInt()); } // 应熟练掌握java数据结构和API Integer target = Integer.valueOf(sc.nextInt()); System.out.println(Collections.frequency(list, target)); } }