Java中Collection集合

【Java集合 1】Java集合,Collection接口,Iterator接口 全网最细Java零基础手把手入门教程,系列课程包括:基础篇、集合篇、Java8新特性、多线程、代码实战,持续更新中(每周1-2篇),适合零基础和进阶提升的同学。 阅读详情

集合体系图

集合和数组的比较

数组:存储同一种数据类型

 特点:

       1.只能存储一种数据类型

       2.一旦初始化,长度固定

       3.数组元素的内存地址是连续的

       4.Object类型的数组可以存储任意类型的元素

 需求:收集同学的兴趣爱好

 集合:存储对象数据的集合容器

 优势:

1. 集合可以存储任意类型的对象信息,数组只能存储同一类型对象信息(Object除外)

2.集合的长度是任意变化的,数组长度是固定的

 

集合的体系结构

--|Collection:单列集合的根接口,表示一组对象

----|List 实现List接口的集合类,特点:有序可以重复

------|ArrayList 维护Object数组实现的,特点:查询快,增删慢

------|LinkedList 底层使用链表数据结构实现的,特点:查询慢,增删快

------|Vector 底部维护Object数组,实现和ArrayList一样,但是Vector是线程安全,效率低

----|Set 实现Set接口的集合类,特点:无序,不可重复

------|HashSet 底层是使用了哈希表来支持的,特点: 存取速度快.

--------|特点:hashSet的实现原理:

           往Haset添加元素的时候,HashSet会先调用元素的hashCode方法得到元素的哈希值 ,

          然后通过元素的哈希值经过移位等运算,就可以算出该元素在哈希表中的存储位置。

          情况1:如果算出元素存储的位置目前没有任何元素存储,那么该元素可以直接存储到该位置上。

 情况2: 如果算出该元素的存储位置目前已经存在有其他的元素了,那么会调用该元素的equals方法与该位置的元素再比较一次,如果equals返回的是true,那么该元素与这个位置上的元素就视为重复元素,不允许添加,如果equals方法返回的是false,那么该元素运行添加。

------|TreeSet

--------|如果元素具备自然顺序的特性,那么就按照元素自然顺序的特性进行排序

双例集合体系

双列集合:

   Map:实现Map接口的集合类,具备的特点:存储的数据都是以键值对的方式,键不可以重复,值可重复

   --|HashMap

底层使用hashCode表来实现向HashMap中添加元素的时候,首先调用键的hashCode方法得到元素的哈希码的值,经过运算,得到该元素在哈希表中的位置;

   1.如果该位置没有存储元素,则元素之间添加到哈希表中

   2.如果该位置有其他的元素,会调用元素的equals方法,如果返回false,该元素被储存,返回true,该元素重复不能存储

   --|TreeMap

TreeMap:基于二叉树的数据结构实现的,会对具备自然特性的键进行排序存储

1.元素的键具备自然特性,直接排序存储

2.不具备自然特性,实现Comparable接口,在ComparaTo中定义排序规则

3.不具备自然特性,没有实现Comparable接口,在创建TreeMap对象的时候传入比较器

   --|HashTable

collection集合

基本使用

package com.cloud.day1;
import java.util.ArrayList;
import java.util.Collection;
/*
--|Collection:单列集合的根接口,表示一组对象
----|List 实现List接口的集合类,特点:有序可以重复
----|Set  实现Set接口的集合类,特点:无序,不可重复
Collection中的方法
	添加
	add(E e) 
	addAll(Collection<? extends E> c) 
	
	删除
	clear() 
	remove(Object o)
	removeAll(Collection<?> c)
	retainAll(Collection<?> c)
	
	查看
	size() 
	
	判断
	contains(Object o) 
	containsAll(Collection<?> c) 
	equals(Object o) 
	isEmpty() 
	
	迭代
	iterator() 
	toArray()
 */
 
public class Demo1 {
	public static void main(String[] args) {
		Collection test=new ArrayList();
		test.add("SHsH");
		test.add("sjf");
		test.add(1);
		Collection c=new ArrayList();
		c.add("Spring");
		c.add(1);
		c.addAll(test);
		System.out.println("添加成功返回值?"+c.add("Summer"));
		//c.clear();
		c.remove("sjf");
		//c.removeAll(test);//删除两个集合的交集
		c.retainAll(test);//保留c集合和test集合的交集元素,其余删除
		
		System.out.println(c);
	}
}	

集合中的函数判断

package com.cloud.day1;
import java.util.ArrayList;
import java.util.Collection;
public class Demo2 {
	public static void main(String[] args) {
		Collection<Person> all=new ArrayList<Person>();
		all.add(new Person(1,"Spring1"));
		all.add(new Person(2,"Spring2"));
		all.add(new Person(3,"Spring3"));
		all.add(new Person(4,"Spring4"));
		System.out.println("判断包含:"+all.contains(new Person(1,"Spring1")));
		System.out.println(all);
	}
}
class Person{
	private int id;
	private String name;
	public Person(int id,String name){
		this.id=id;
		this.name=name;
	}
	public String toString() {
		return "编号:"+this.id+";姓名:"+this.name;
	}
	/**
	 * 重写比较方法
	 */
	public boolean equals(Object obj) {
		Person p=(Person) obj;//向下转型
		return this.id == p.id;
	}
	/**
	 * java的规范,重写equals方法就会重写hashCode方法
	 */
	public int hashCode() {
		return this.id;
	}
}

迭代输出集合元素

package com.cloud.day1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class Demo3 {
	public static void main(String[] args) {
		Collection c=new ArrayList();
		c.add("Spring1");
		c.add("Spring2");
		c.add("Spring3");
		/*迭代器输出元素
		Iterator it=c.iterator();
		while(it.hasNext()){
			System.out.println(it.next());
		}
		
		
		for(Iterator it=c.iterator();it.hasNext();){
			System.out.println("["+it.next()+"]");
		}
		*/
		//remove:方法删除最后一次返回的元素
//		Iterator it=c.iterator();//这时候获取一个迭代器还没有获取元素
//		it.next();
//		it.remove();//删除Spring1
		
//		Iterator it=c.iterator();//这时候获取一个迭代器还没有获取元素
//		it.next();
//		it.next();
//		it.remove();//删除Spring2
		
		//删除全部
		Iterator it=c.iterator();//这时候获取一个迭代器还没有获取元素
		while (it.hasNext()){
			it.next();
			it.remove();
		}
		System.out.println(c);
	}
}

模拟登录注册案例

package com.cloud.day1;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Scanner;
public class Demo4 {
	/**
	 * @param模拟注册登录的案例
	 * 1.如果用户名和密码已经存在,则注册失败
	 * 2.则注册成功
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		Collection users=new ArrayList();
		while(true){
			System.out.println("请选择功能:A.注册  B.登录");
			String option=scanner.next();
			if("a".equalsIgnoreCase(option)){
				System.out.println("你选择了注册功能");
				User user=null;
				while (true){
					System.out.println("请输入账号...");
					int id=scanner.nextInt();
					user=new User(id, null);
					if(users.contains(user)){
						System.out.println("该用户已经存在,重新输入...");
					}
					else{
						break;
					}
				}
				System.out.println("请输入密码...");
				String password=scanner.next();
				user.setPassword(password);
				//存入集合中
				users.add(user);
				System.out.println("注册成功");
				System.out.println("注册人员信息"+users);
				/*
				System.out.println("你选择注册功能");
				while(true){
					System.out.println("请输入账号...");
					int id=scanner.nextInt();
					//遍历集合是否存在该账号
					Iterator it=users.iterator();
					while(it.hasNext()){
						User user=(User) it.next();
						if(user.id==id){
							System.out.println("该账号已经被注册,重新输入...");
							break;
						}
					}
				}
				*/
			}
			else if("b".equalsIgnoreCase(option)){
				System.out.println("你选择登录功能");
				System.out.println("请输入账号...");
				int id=scanner.nextInt();
				System.out.println("请输入密码...");
				String password=scanner.next();
				//遍历集合元素查看用户信息
				boolean isLogin=false;
				Iterator it=users.iterator();
				while(it.hasNext()){
					User user=(User) it.next();
					if(user.id==id && user.password.equals(password)){
						isLogin=true;
					}
				}
				if(isLogin){
					System.out.println("欢迎进入...");
				}
				else{
					System.out.println("用户名或者密码错误");
				}
			}
			else{
				System.out.println("你的选择错误,重新输入");
			}
		}
	}

}
class User{
	int id;
	String password;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public User(int id,String password){
		this.id=id;
		this.password=password;
	}
	@Override
	public boolean equals(Object obj) {
		User user=(User) obj;
		return this.id==user.id;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "(账号:"+this.id+",密码:"+this.password+")";
	}
}

Collections集合的工具类

package com.cloud.collection;

 

import java.util.ArrayList;

import java.util.Collections;

import java.util.Comparator;

/*

笔试题:Collection和Collections区别

Collection是单例集合的根接口

Collections是操作集合对象的工具类

 */

class Person{

   String name;

   int age;

   public Person(String name,int age){

      this.name=name;

      this.age=age;

   }

   @Override

   public String toString() {

      return "[姓名:"+this.name+";年龄:"+this.age+"]";

   }

}

//自定义一个比较器

class AgeComparator implements Comparator<Person>{

   @Override

   public int compare(Person o1, Person o2) {

      return o1.age - o2.age;

   }

}

public class Demo1 {

   public static void main(String[] args) {

      ArrayList<Integer> arr = new ArrayList<Integer>();

      arr.add(6);

      arr.add(4);

      arr.add(2);

      Collections.sort(arr);

      //二分查找,要先排序

      System.out.println("元素索引的位置:"+Collections.binarySearch(arr, 2));

      System.out.println("max="+Collections.max(arr));

      System.out.println("min="+Collections.min(arr));

      //数组翻转

      Collections.reverse(arr);

      System.out.println(arr);

      ArrayList<Person> arr1 = new ArrayList<Person>();

      arr1.add(new Person("a",5));

      arr1.add(new Person("c",3));

      arr1.add(new Person("b",6));

      AgeComparator act = new AgeComparator();

      Collections.sort(arr1, act);

      System.out.println(Collections.binarySearch(arr1, new Person("a",5),act));

      System.out.println(arr1);

   }

}

java集合框架Collection java集合框架 java.util.Collection接口 Collection接口中定义了所有集合都要具备的功能,它也是所有集合的顶级接口。 Collection下面有几种不同集合的分类,常见的两个: 1.java.util.List:List接口表示的是线性表,是有序的且可以存放重复元素的集合 * 2.java.util.Set:Set接口表示的是不可重复的集合 这里指的重复是元素是... 阅读详情

相关推荐

工业质检实战:用海康VisionMaster的BLOB分析搞定PCB焊点缺陷检测

本文详细介绍了如何利用海康VisionMaster平台的BLOB分析技术,构建一套针对PCB焊点缺陷的自动化视觉检测方案。文章从核心原理出发,重点阐述了如何通过动态阈值分割和模板匹配定位,克服工业现场光照不均、位置偏移等挑战,实现虚焊、漏焊等缺陷的精准、稳定检测,并提供了实战调优与系统集成的关键思路。

weixin_29091105的博客 563

java 双列集合Map 万字详解

java 集合篇章——Map集合总结。

优快云 / 稀土掘金/ B站 / GitHub: Cyan_RA9 2240

Simulink中Simscape—Fluids模块(原Simhydraulics)学习记录

学习来源:http://cn.mathworks.com/help/physmod/hydro/getting-started-with-simhydraulics.html 主要学习内容如下图: 详细内容: 1、组件来源 SIMULINK浏览器中的模块:Simscape_Foundation 和 Simscape_Fluids。 2、Simscape下包括多个子

1万+

Java之双列集合

比Set接口常用1.不同于单列集合只传一个对象,双列集合都是传两个对象2.Node类是HashMap的内部类符号表示HashMap$Nodenext把所有的Node元素连接然后对应数组索引可以调用到对应索引的第一个Node元素拿到第一个Node元素相当于后面都有了Node源码3和4.key不能重复,value可以重复,可以重复的话会替换原来key的value5.6.也可以用其他类的对象做key,因为形参是Objectkey7.通过如图。............

y_k_j_c的博客 939

【ChatGPT实战案例】ChatGPT如何帮助产品经理高效工作?

1. 产品经理主要工作方向, 2. 具体工作中,向ChatGPT提问参考

weixin_62909516的博客 1900

达梦数据库JDBC连接池断开自动重连设置

一、场景 在网络状况不是非常良好,经常会出现暂时性的拥塞或者断开的情况,而且当我们重启数据库时也会发生类似的情况。所以需要配置中间件的连接池来实现连接测试以及自动重连,通过重新配置连接池,成功解决了这个问题。下面会给出一份数据源配置参数详单和一份推荐的数据源配置项。 二、连接池配置参数 1. initialSize:连接池启动时创建的初始化连接数量 2. maxActive:连接池中可同时连接的最大的连接数 3. maxIdle:连接池中最大的空闲的连接数,超过的空闲连接将被释放,如果设置为负

lilv1989的博客 7237

在xml中collection、association的用法

在xml中collection、association用法

m0_52563512的博客 3542

图神经网络在金融风险传播分析中的应用

《图神经网络在金融风险传播分析中的应用》 摘要 本文旨在探讨图神经网络(Graph Neural Networks, GNN)在金融风险传播分析中的应用。首先,本文简要介绍了图神经网络的基本概念、发展历史以及其在各类应用场景中的重要性。接着,详细介绍了图神经网络的核心算法,包括图卷积神经网

AI天才研究院 1282

HashMap的底层原理jdk1.7和jdk1.8的实现的区别

HashMap的底层原理jdk1.7和jdk1.8的实现的区别

ratel的博客 1827

星载SAR的各项指标解读(史上最全)

一、系统指标 系统指标主要指雷达系统的通用的指标,以及和卫星整星相关的指标,主要有一下几项: 工作频段: 雷达体制: 极化方式: 设计s

9273

【模型之美】3、文本聚类与智能摘要,让AI帮你做个总结

在信息过载时代,文本聚类与摘要技术成为关键工具。本文提出了一种结合OpenAI Embedding与传统机器学习的方法,实现从文本预处理到智能分析的完整流程。技术方案分为三阶段:1)通过Embedding将文本转化为语义向量;2)采用K-Means等算法进行无监督聚类;3)利用大模型生成可解释的标签和摘要。实验证明,该方法能有效提升信息处理效率,如在新闻聚合系统中自动分类10,000篇文章,准确率较传统方法提高15%。方案包含实用代码示例,涵盖文本清洗、向量化、聚类优化等关键技术细节,可应用于对话记忆、舆情

2025博客之星Top81。专注AI工程化与架构实战。从分布式思维到模型部署,用工程化视角为你厘清AI落地的真实路径。 1440

浅说java的xml中的foreach用法

三、当mapper中的参数是多个,都需要绑定@Param注解,此时xml中collection的值是绑定注解的参数(无论参数是数组还是集合)如果传入的是单参数且参数类型是一个array数组的时候,collection的属性值为array。如果传入的是单参数且参数类型是一个List的时候,collection属性值为list。在使用foreach的时候最关键的也是最容易出错的就是collection属性,该属性是必须指定的,但是在不同情况 下,该属性的值是不一样的,item :表示集合中的每一个元素。

qq_43380361的博客 2611

科研必备:15款顶尖AI科研工具全面分析汇总(持续更新ing)

科研必备:15款AI科研工具全面分析汇总(持续更新ing)

Code_流苏:在代码中寻诗意,在实践中觅真知 9660

java集合进阶篇-《Collection集合》

java中的集合也是一个重点,同样也是难点,涉及到的东西较多较杂,希望大家能够和我一起来学习java集合进阶方面的知识。预计一周的时间将java集合进阶部分拿下,加油。在Java中,是一个接口,它是所有Java集合框架的根。它定义了集合类必须实现的基本操作,如添加元素、删除元素、迭代等。所有的集合类(如ListSetQueue等)都是Collection接口的直接或间接实现。

欢迎大家一起讨论交流 1053

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

java集合之——Collection接口

前言 老师在教我们学习集合的时候,大多都是以数组为砖,列举了对象数组有那些问题?比如普通的对象数组的最大问题在于数组中的元素个数是固定的,不能动态的扩充大小,所以最早的时候可以通过链表实现一个动态对象数组。但是这样做毕竟太复杂了,所以在 Java 中为了方便用户操作各个数据结构,所以引入了类集的概念,有时候就可以把类集称为 java 对数据结构的实现。 在整个类集中的,这个概念是从 JDK 1.2(Java 2)之后才正式引入的,最早也提供了很多的操作类,但是并没有完整的提出类集的完整概念。 类集中最大的几

you do ,you win 4310

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

JAVA学习-集合-Collection

认识集合,操作集合。

LOVEcao_YU的博客 979

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

【JavaSE系列】Java集合框架之Collection,Map接口

本篇文章带大家认识Java基础知识——集合框架,从本篇文章开始正式拉开数据结构的序幕,要深入了解一件事,那必然先得见个面,本文带大家认识Java集合框长什么样,以及怎么使用Collection和Map接口。

未见花闻的博客 1832

【Java】集合之Collection概述

目录 一、前言 二、常见的集合概览图 三、Collection集合 1.Collection集合常用方法 2.Collection集合之迭代器 迭代器介绍 迭代器常用方法: 一、前言 集合在Java中的作用是显而易见的,他可以存储我们的信息,可以实现增删减改的 操作,相当于一个模拟的"数据库"。 二、常见的集合概览图 集合都是在java.util包下的,所以在使用时先导包。 三、Collection集合 public interface Collection&.

weixin_60719453的博客 2437

java集合Collection

Collection集合:分为单列集合 和 多列集合 单列集合:List、Set、Queue集合;多列集合:Map集合

LXMXHJ的博客 1611

Java——Collection集合

Collection集合

m0_72786443的博客 415

Java中的Collection集合

JAVASE提供了满足各种需求的API,在使用这些API前,先了解其继承与接口操作架构,才能了解何时采用哪个类,以及类之间如何彼此合作,从而达到灵活应用。 集合按照其存储结构可以分为两大类,分别是单列集合java.util.Collection和双列集合java.util.Map本文主要讲Collection集合,后续再补充Map集合。

write less , do more 3443

Java 集合框架(Collection)

这个方法允许你指定数组的类型,并且可以避免类型转换的开销。相关的方法,当然,Collection的功能List也都继承了。1.LinkedList集合的底层是基于什么实现的?① 如果集合支持索引,可以使用for循环遍历,每删除数据后做。获取集合的迭代器对象,对迭代器对象使用.next()方法。基于双链表的这种特点,LinkedList新增了很多。写累了,承受了这个年纪不该承受的(惆怅脸)…函数式接口的实现,这个实现可以是一个。就是removeFirst方法的套皮,来实现的,但隐藏了迭代器的实现细节。

m0_70484213的博客 1169

Java—— 单列集合 Collection

单列集合体系结构。Collection介绍。常用方法。Collection的遍历方式:迭代器遍历。增强for遍历。Lambda表达式遍历。

zjy_ccccc的博客 760

java中collection集合

可以把它理解成:一个 “装东西的容器”,这个容器规定了 “怎么加东西、怎么删东西、怎么看有多少东西”,但不规定 “东西怎么摆”(比如是有序还是无序、是否允许重复)。包下),它定义了一组用于操作「多个元素」的通用方法,是所有单列集合(区别于 Map 这种键值对集合)的 “总规则”。迭代器是 Collection 遍历的「标准方式」,专门用于安全地遍历集合(避免遍历中修改集合导致的异常)。注:Queue(队列)也是 Collection 的子接口,属于进阶内容,后面会讲。三、深入理解:迭代器 & 遍历(进阶)

wuilwxxxxx的博客 363

Java 的 Collection 集合体系

Java集合框架(JCF)提供了一套标准化的接口和实现,用于存储和操作对象组。核心接口包括: 1️⃣ Collection(单列集合根接口) 2️⃣ List(有序可重复,实现类:ArrayList、LinkedList等) 3️⃣ Set(无序唯一,实现类:HashSet、TreeSet等) 4️⃣ Queue(队列,含Deque双端队列) 主要特点: ArrayList基于动态数组,随机访问快;LinkedList基于链表,插入删除快 HashSet基于哈希表查询最快;TreeSet基于红黑树保持有序

2301_80215285的博客 1070

Java集合进阶 单列集合collection和list

Java当中一共有很多种集合之前学过的ArrayList只是其中的一类。Collection单列集合:添加一个元素Map双列集合:添加俩个元素。

2302_80073130的博客 2063
上一篇: Servlet中的编码
下一篇: JSP基本概念
午-夜
博客等级 码龄12年 95粉丝 133原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值