Skip to content

Commit 4bc7b98

Browse files
committed
Java第十七天
1 parent 36c0c37 commit 4bc7b98

File tree

66 files changed

+1556
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1556
-0
lines changed

day17/code/Collection集合总结.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
1��Collection������ϵ�ṹ
2+
Collection
3+
|--List(Ԫ�����򣬿��ظ�)
4+
|--ArrayList
5+
�ײ����ݽṹ�����飬��ѯ��,��ɾ��
6+
�̲߳���ȫ,Ч�ʸ�
7+
|--Vector
8+
�ײ����ݽṹ�����飬��ѯ��,��ɾ��
9+
�̰߳�ȫ,Ч�ʵ�
10+
|--LinkedList
11+
�ײ����ݽṹ����������ѯ��,��ɾ��
12+
�̲߳���ȫ,Ч�ʸ�
13+
|--Set(Ԫ������Ψһ)
14+
|--HashSet
15+
�ײ����ݽṹ�ǹ�ϣ����
16+
��֤Ԫ�ص�Ψһ��?
17+
������������hashCode()��equals()��
18+
|--LinkedHashSet
19+
�ײ����ݽṹ�ǹ�ϣ��������
20+
�ɹ�ϣ����֤Ԫ��Ψһ
21+
��������֤Ԫ������
22+
|--TreeSet
23+
�ײ����ݽṹ�Ƕ�����(�����)
24+
��֤Ԫ�ص�Ψһ��?
25+
���ݱȽϵķ���ֵ�Ƿ���0
26+
��֤Ԫ�ص�����?
27+
��Ȼ����
28+
�Ƚ�������
29+
30+
2�����Collection����׼��ʹ��˭?
31+
Ԫ��Ψһ��?
32+
�ǣ�Set
33+
Ҫ������?
34+
�ǣ�TreeSet
35+
��HashSet
36+
37+
��֪��������HashSet
38+
��List
39+
Ҫ��ȫ��?
40+
Ҫ��Vector(��ʵҲ���ã��и��õķ�ʽ�����潲)
41+
��Ҫ��ArrayList����LinkedList
42+
��ѯ�ࣺArrayList
43+
��ɾ�ࣺLinkedList
44+
45+
��֪��������ArrayList
46+
47+
��֪��������ArrayList
48+
49+
3�������е����ݽṹ����
50+
ArrayXxx:�ײ����ݽṹ�����飬��ѯ�죬��ɾ��
51+
LinkedXxx:�ײ����ݽṹ����������ѯ������ɾ��
52+
HashXxx:�ײ����ݽṹ�ǹ�ϣ����������������hashCode()��equals()���������ѡ���Ƿ��Զ���д
53+
TreeXxx:�ײ����ݽṹ�Ƕ������������ַ�������Ȼ���򣬱Ƚ�������
Binary file not shown.
Binary file not shown.

day17/code/day17_List_test/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

day17/code/day17_List_test/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>day17_List_test</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cn.itcast_01;
2+
3+
import java.util.ArrayList;
4+
5+
/*
6+
* 需求:获取10个1-20之间的随机数,要求不能重复
7+
*
8+
* 分析:
9+
* A:定义一个集合,用于存储产生的随机数
10+
* B:定义一个统计变量,初始值是0
11+
* C:判断统计变量是否小于10
12+
* 是:
13+
* 产生一个随机,然后判断是在集合中
14+
* 是:不添加
15+
* 否:添加到集合
16+
* 否:结束
17+
* D:遍历集合
18+
*/
19+
public class RandomNumberDemo {
20+
public static void main(String[] args) {
21+
// 定义一个集合,用于存储产生的随机数
22+
ArrayList<Integer> array = new ArrayList<Integer>();
23+
24+
// 定义一个统计变量,初始值是0
25+
int count = 0;
26+
27+
// 判断统计遍历是否小于10
28+
while (count < 10) {
29+
// 产生一个随机,然后判断是在集合中
30+
int randomNumber = (int) (Math.random() * 20) + 1;
31+
32+
if (!array.contains(randomNumber)) {
33+
array.add(randomNumber);
34+
count++;
35+
}
36+
}
37+
38+
// 遍历集合
39+
for (Integer i : array) {
40+
System.out.println(i);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)