【学习心得】-对一维数组增加或删除数据
2009-12-05 11:07
405 查看
class TT_2 { //set the value to save the length of runtiming LinerArray; private int num; //set the name of the String Array; private String[] data; //set the LinerArray's size; public TT_2(int s) { //the part of allowing errors; if(s <= 0) s = 10; //the part of setting; data = new String[s]; num = 0; } //Judge Full; public boolean IsFull() { if(num >= data.length) return true; return false; } //Judge Empty; public boolean IsEmpty() { if(num == 0) return true; return false; } //Insert a value; public void Insert(String value,int pos) { if(!IsFull() && (pos >= 0 && pos <= num)) { for(int i = num - 1;i >= pos;i--) data[i + 1] = data[i]; data[pos] = value; num++; } } //Delte a vlaue; public void Delte(String value,int pos) { if(!IsEmpty() && (pos >= 0 && pos <= num - 1)) { for(int i = pos;i <= num - 1;i++) data[i] = data[i + 1]; num--; } } //Disply the Array; public void PrintA() { for(int i = 0;i < num;i++) System.out.print(data[i] + "/t"); System.out.println(); System.out.println(); System.out.println("The programming is end!"); } //Main method; public static void main(String[] args) { TT_2 T = new TT_2(10); T.Insert("A",0); T.Insert("B",0); T.Insert("C",0); T.PrintA(); } }
相关文章推荐
- 数据存储——Java数组,去掉重复值、增加、删除数组元素的实现方法
- 【OpenCV学习】一个多维数组(矩阵)和一个一维,但是包含高维数据的数组之间的区别
- MySQL学习笔记 第八讲:增加、删除、更新数据和备份还原
- OpenCV学习——一个多维数组(矩阵)和一个一维,但是包含高维数据的数组之间的区别
- 面向对象处理人员数据 (动态数组,人员数据的增加与删除)
- 一维数组的增加,删除,找最大数
- JAVA学习心得--基本数据类型,输入、输出,数组
- JPA学习笔记---JPA数据的操作:增加,删除,修改,获取,使用JPQL进行查询
- javascript学习碎片---js对表格数据修改、增加、删除,获取行列数据,打包为json数据包
- treeview学习2之体验报告:绑定数据(递归算法),增加节点,删除节点
- javaScript学习笔记——数组末尾元素的增加和删除
- WCF学习心得------(六)数据协定
- matlab读取一维数组数据,并显示直方图分布,不同分段显示不同颜色
- mysql命令行命令和SQL语句,MySQL修改删除增加字段类型,字段数据等。。
- 我的MYSQL学习心得(四) 数据类型
- 用asp增加、删除access数据表和字段
- 数据库中两张表之间的数据同步增加、删除与更新
- C++学习--向txt文件写入数据、读取数据、获取行数以及删除文件
- 大数据学习心得
- php 数组操作(增加,删除,查询,排序)等函数说明第1/2页