Java 实例 - 集合长度
Java 教程
· 2019-02-11 15:57:46
以下实例演示了如何使用 Collections 类 的collection.add() 来添加数据并使用 collection.size()来计算集合的长度:
Main.java 文件
import java.util.*;
public class Main {
public static void main(String [] args) {
System.out.println( "集合实例!\n" );
int size;
HashSet collection = new HashSet ();
String str1 = "Yellow", str2 = "White", str3 =
"Green", str4 = "Blue";
Iterator iterator;
collection.add(str1);
collection.add(str2);
collection.add(str3);
collection.add(str4);
System.out.print("集合数据: ");
iterator = collection.iterator();
while (iterator.hasNext()){
System.out.print(iterator.next() + " ");
}
System.out.println();
size = collection.size();
if (collection.isEmpty()){
System.out.println("集合是空的");
}
else{
System.out.println( "集合长度: " + size);
}
System.out.println();
}
}
以上代码运行输出结果为:
集合实例! 集合数据: White Yellow Blue Green 集合长度: 4
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
数据驱动设计
[美]罗谢尔·肯(RochelleKing)、[美]伊丽莎白F.邱吉尔(Elizabeth F Churchill)、Caitlin Tan / 傅婕 / 机械工业出版社 / 2018-8 / 69.00元
本书旨在帮你了解数据引导设计的基本原则,了解数据与设计流程整合的价值,避免常见的陷阱与误区。本书重点关注定量实验与A/B测试,因为我们发现,数据分析与设计实践在此鲜有交集,但相对的潜在价值与机会缺大。本书提供了一些关于在组织中开展数据实践的观点。通过阅读这本书,你将转变你的团队的工作方式,从数据中获得大收益。后希望你可以在衡量指标的选择、佳展示方式与展示时机、测试以及设计意图增强方面,自信地表达自......一起来看看 《数据驱动设计》 这本书的介绍吧!