package arrays.myArray;
public class MyArrayList {
private Object[] arrObj = new Object[3];
private int size = 0;
// 长度
public int size() {
return size;
}
// insert
public void add(Object obj) {
add(size,obj);
}
// update
// 把前面的往后移动
public void add(int index, Object obj) {
if(size==arrObj.length){
Object[] temp=new Object[size*2];
for(int i=0;i<arrObj.length;i++){
temp[i]=arrObj[i];
}
arrObj=temp;
}
//从前往后
for (int i =size; i>index ; i--) {
arrObj[i] = arrObj[i-1];
}
arrObj[index]=obj;
size++;
}
// delete
// 把后面的往前移动
public void remove(int index) {
size--;
for (int i =index;i<size; i+ ......
package arrays.myArray;
public class MyLinkedList {
private int size = 0;
private Node1 head = null;
// 添加
public void add(Object obj) {
add(size, obj);
}
// 修改
public void add(int index, Object obj) {
if (null == head) {
head = new Node1(obj, null);
} else {
if (0 == index) {
head = new Node1(obj, head);
} else {
Node1 temp = head;
for (int i = 0; i < index - 1; i++) {
temp = temp.next;
}
temp.next = new Node1(obj, temp.next);
}
}
size++;
}
// 移除
public void remove(int index) {
if (0 == index) {
head = head.next;
} else {
Node1 temp = head;
&nbs ......
package arrays.myArray;
public class SortArr {
public static void main(String[] args) {
int[] arrInt = { 4, 7, 8, 5, 6, 3, 2, 3, 4 };
maoPaoSort(arrInt);
print("冒泡排序:", arrInt);
arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
insertSort(arrInt);
print("插入排序:", arrInt);
arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
checkSort(arrInt);
print("选择排序:", arrInt);
}
// 冒泡排序
private static void maoPaoSort(int[] arrInt) {
int temp = 0;
for (int i = 0; i < arrInt.length; i++) {
for (int j = 0; j < arrInt.length - 1; j++) {
if (arrInt[i] < arrInt[j]) {
temp = arrInt[i];
arrInt[i] = arrInt[j];
arrInt[j] = temp;
}
}
&nbs ......
package arrays.myArray;
import java.util.Scanner;
public class SortObject {
private static int intercePosition = 0; // 记录单个运算数据的长度
private static int[] intercePositionIndex = null; // 记录“(”的下标
private static int[] intercePositionEnd = null; // 记录“)”的下标
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
do {
System.out.println("请输入你要计算的字符串(注意:只能输入数字和加,减,乘除符号;输入完毕后,请直接回车):");
String numberString = input.next().trim();
// 判断输入的运算字符串是否符合规定
if (ispassString(numberString) == false) {
System.out.println("您输入的计算字符串有误,请正确输入!");
} else {
// 计算结果返回
System.out.println(interceResult(numberString));
}
  ......
package collection;
import java.util.*;
public class NewArrayList {
public static void main(String[] args) {
List<Student> students = new ArrayList<Student>();
for (int i = 0; i < 6; i++) {
students.add(new Student("Happy"+i,"male"+i,20+i));
}
print(students);
print2(students);
}
//循环遍历①for
public static void print(List<Student> newList){
System.out.println("总数据:"+newList.size());
Student student;
for (int i = 0; i < newList.size(); i++) {
student = (Student)newList.get(i);
System.out.println(student.toString());
}
}
//循环遍历①Iterator
public static void print2(List<Student> newList){
System.out.println("总数据:"+newList.size());
Iterator<Student> iterator = newList.iterator();
  ......
package collection;
import java.util.*;
public class NewSet {
public static void main(String[] args) {
Set<Student> students = new HashSet<Student>();
for (int i = 0; i < 6; i++) {
students.add(new Student("Happy"+i,"male"+i,20+i));
}
students.add(new Student("Happy0","male0",20));
print(students);
print2(students);
}
//循环遍历①for
public static void print(Set<Student> newList){
System.out.println("总数据:"+newList.size());
/*Student student;
for (int i = 0; i < newList.size(); i++) {
student = (Student)newList
System.out.println(student.toString());
}*/
}
//循环遍历①Iterator
public static void print2(Set<Student> newList){
System.out.println("总数据:"+newList.size());
Iterator<Stu ......