基于Java集合的房源出租信息系统设计与实现
2021-03-28吴飞燕
吴飞燕



摘 要:在Java面向对象程序设计中,创建数组时必须指明数组的长度,且长度固定、不能改变,同一个数组只能存放同一种数据类型的数据。然而,在实际情况下,数据的个数和类型需要根据实际情况进行相应的调整的。为此,提出选择Java中合适的集合容器List接口、ArrayList实现类来设计并实现房源出租信息系统。实践表明,该方法可以提高开发效率。
关键词:Java集合框架;List接口;ArrayList类;房源出租
中图分类号:TP311.13 文献标识码:A 文章编号:1003-5168(2021)29-0015-04
Design and Implementation of House Rental Information
Management Based on Java Collection
WU Feiyan
(College of Internet of Things, Jiangxi Teachers College,Yingtan Jiangxi 335000)
Abstract: In java object-oriented programming, when creating an array, the length of the array must be specified, and the length is fixed and cannot be changed. The same array can only store data of the same data type. However, in practice, the number and type of data are adjusted accordingly. Therefore, to propose to select the appropriate collection container list interface and ArrayList implementation class in Java to design and implement the house rental information system. Practice shows that this method can improve the development efficiency.
Keywords: Java collection framework;List interface;ArrayList class;house rental
集合(Collection)[1]也叫作容器(Container),是一种将多个元素聚合起来组成一个单元的对象。它常常用来储存、检索、操作聚合的数据。集合与数组的区别有以下3点:①长度区别,数组的长度固定,不可更改,而集合长度可变,在保证不超出内存的前提下,可以随时添加和删除元素;②内容区别,数组可以存放基本类型数据和引用类型数据,集合只能存放引用类型数据;③元素内容区别,数组只能存储同一种类型的数据,而集合可以存储不同类型的数据。
1 Java集合框架
Java集合框架[2](Java Collections Framework)是Sun公司发布的Java应用程序编程接口(Application Programming Interface,API)的重要组成部分,存放于java.util包中。Java平台的集合框架提供了一个表示和操作对象集合的统一架构,允许用户独立地操作各种数据结构而不需要了解具体的实现。Java集合框架包含大量集合接口(Interfaces),具有这些接口的实现类(Implementations)和操作它们的算法(Algorithms)。接口是代表集合的抽象数据类型;实现类是集合接口的具体实现,从本质上讲,它们是可重复使用的数据结构;算法是实现集合接口对象里的方法执行的一些有用计算,如搜索和排序。……
