当前位置:网站首页>Exercise (1) create a set C1 to store the elements "one", "two", "three"“
Exercise (1) create a set C1 to store the elements "one", "two", "three"“
2022-07-25 23:53:00 【JOJO, baby】
The original title is : * Create a collection c1, Store elements "one","two","three" * Create another collection c2, Store elements "four","five","six" * And then c2 All elements are stored c1 aggregate * Then create the set c3, Store elements "one,five" * Then output the set c1 Whether to include a collection c3 All elements of * And then c1 In the collection "two" Delete before exporting c1 aggregate 、
Source code
public static void main(String[] args) {
// Create a collection c1, Store elements "one","two","three"
Collection<String> c1 =new ArrayList<String>();
c1.add("one");
c1.add("two");
c1.add("three");
// Create another collection c2, Store elements "four","five","six"
Collection<String> c2 =new ArrayList<String>();
c2.add("four");
c2.add("five");
c2.add("six");
// And then c2 All elements are stored c1 aggregate
System.out.println(c2.addAll(c1));
// Then create the set c3, Store elements "one,five"
Collection<String> c3 = new ArrayList<String>();
c3.add("one,five");
// Then output the set c1 Whether to include a collection c3 All elements of
System.out.println(c1.containsAll(c3));
// And then c1 In the collection "two" Delete before exporting c1 aggregate
c1.remove("two");
System.out.println(c1);
}边栏推荐
猜你喜欢

Shardingsphere data slicing

智牛股--09

LeetCode 0135. 分发糖果

redis-基本数据类型(String/list/Set/Hash/Zset)

Generating random number random learning uniform_ int_ distribution,uniform_ real_ distribution

Inheritance (the child constructor inherits the attributes in the parent constructor)

Redis basic data type (string/list/set/hash/zset)

R语言安装教程 | 图文介绍超详细

What is the difference between'1 and'b1 when assigning values

How does JS judge whether the current date is within a certain range
随机推荐
Part 67: conversion between keypoint and point2f in opencv
Function definition and call
智牛股--09
From which dimensions can we judge the quality of code? How to have the ability to write high-quality code?
1223. Dice simulation range DP
[testing technology automated testing pytest] basic summary of pytest
行为型模式之迭代器模式
指针函数的demo
C language implementation of three chess
The difference between SFTP and FTP
How to solve cross domain problems
Lua script Wireshark plug-in to resolve third-party private protocols
How does JS judge whether the current date is within a certain range
[intelligence question] interview intelligence question
typescript ts 基础知识之类
[nodejs] nodejs create a simple server
Promise resolve callback hell, async await modifier
Vscode format JSON file
1223. 掷骰子模拟 范围DP
在应用中使用 Jetpack 库