From 78cf4219d8cc3f4a6e5a46f52245588203bb75e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BF=97=E5=BC=BA?= <3165279696@qq.com> Date: Mon, 6 May 2024 20:31:40 +0800 Subject: [PATCH 1/5] 0506 --- .../AirPlane.java" | 29 ++++++++++++ .../Car.java" | 32 +++++++++++++ .../Main.java" | 15 ++++++ .../Vehicle.java" | 46 +++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 "work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/AirPlane.java" create mode 100644 "work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Car.java" create mode 100644 "work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" create mode 100644 "work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Vehicle.java" diff --git "a/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/AirPlane.java" "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/AirPlane.java" new file mode 100644 index 00000000..fd4af297 --- /dev/null +++ "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/AirPlane.java" @@ -0,0 +1,29 @@ +package com.java.minxi.java_20240506.java_2301_刘志强_2344310107; + +public class AirPlane extends Vehicle { + private String plane; + public void setPlane(){ + this.plane = plane; + } + public String getPlane(){ + return plane; + } + public void travel() { + System.out.println("开着" + getColor() + getBrand() + "前往" + getPlane() + "旅游"); + } + public String combination(String Brand){ + return Brand; + } + public String combination(String Brand, String Color) { + return Brand + Color; + } + + public AirPlane(String plane) { + this.plane = plane; + } + + public AirPlane(String color, String brand, String type, String plane) { + super(color, brand, type); + this.plane = plane; + } +} diff --git "a/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Car.java" "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Car.java" new file mode 100644 index 00000000..3f14724d --- /dev/null +++ "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Car.java" @@ -0,0 +1,32 @@ +package com.java.minxi.java_20240506.java_2301_刘志强_2344310107; + + class Car extends Vehicle{ + private String plane; + public void setPlane(){ + this.plane = plane; + } + public String getPlane(){ + return plane; + } + + + + public void travel() { + System.out.println("开着" + getColor() + getBrand() + "前往" + getPlane() + "旅游"); + } + public String combination(String Brand){ + return Brand; + } + public String combination(String Brand, String Color) { + return Brand + Color; + } + + public Car(String plane) { + this.plane = plane; + } + + public Car(String color, String brand, String type, String plane) { + super(color, brand, type); + this.plane = plane; + } + } diff --git "a/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" new file mode 100644 index 00000000..6e28453c --- /dev/null +++ "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" @@ -0,0 +1,15 @@ +package com.java.minxi.java_20240506.java_2301_刘志强_2344310107; + +public class Main { + + public static void main(String[] args) { + Vehicle car1 = new Car("汽车","大众","白色","北京"); + Car car2 = new Car("汽车","奔驰","","东山岛"); + car1.travel(); + car2.travel(); + AirPlane airPlane1 = new AirPlane("蓝色","波音",null,"大理"); + AirPlane airPlane2 = new AirPlane("","空客","客机","哈尔滨"); + airPlane1.travel(); + airPlane2.travel(); + } +} diff --git "a/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Vehicle.java" "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Vehicle.java" new file mode 100644 index 00000000..11afd07d --- /dev/null +++ "b/work/com/java/minxi/java_20240506/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Vehicle.java" @@ -0,0 +1,46 @@ +package com.java.minxi.java_20240506.java_2301_刘志强_2344310107; + +public class Vehicle { + private String plane; + private String Color; + private String Brand; + private String type; + public void travel(){ + System.out.println(); + } + public void setType(String type){ + this.type = type; + } + public String getType(String type){ + return type; + } + + public String getColor() { + return Color; + } + + public void setColor(String color) { + Color = color; + } + + public String getBrand() { + return Brand; + } + + public void setBrand(String brand) { + Brand = brand; + } + + public Vehicle() { + + } + + + public Vehicle(String color, String brand, String type) { + Color = color; + Brand = brand; + this.type = type; + } +} + + -- Gitee From 6b2794ac6b6f2c89ac6d9948debdd30f2bf51dc7 Mon Sep 17 00:00:00 2001 From: LZQ <3165279696@qq.com> Date: Wed, 8 May 2024 19:37:21 +0800 Subject: [PATCH 2/5] 0507 --- .../Bus.java" | 14 ++++++++++++++ .../ControlTemperature.java" | 5 +++++ .../Main.java" | 14 ++++++++++++++ .../MoneyFare.java" | 5 +++++ .../MotorVehicles.java" | 6 ++++++ .../Taxi.java" | 18 ++++++++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" create mode 100644 "work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" new file mode 100644 index 00000000..591c15b2 --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" @@ -0,0 +1,14 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public class Bus extends MotorVehicles implements MoneyFare{ + @Override + public void charge(String c) { + System.out.println("公共汽车:" + c + "元/张,不计算公里数"); + } + + @Override + public void brake(String s) { + System.out.println("公共汽车使用的刹车技术:" + s); + } +} + diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" new file mode 100644 index 00000000..30d22f24 --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" @@ -0,0 +1,5 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public interface ControlTemperature { + public void controlAirTemperature(String t); +} diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" new file mode 100644 index 00000000..28781513 --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" @@ -0,0 +1,14 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public class Main { + public static void main(String[] args) { + Bus bus = new Bus(); + bus.brake("气式"); + bus.charge("2"); + + Taxi taxi = new Taxi(); + taxi.brake("油式"); + taxi.charge("1"); + taxi.controlAirTemperature("嵌入式空调"); + } +} diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" new file mode 100644 index 00000000..705a9bdb --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" @@ -0,0 +1,5 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public interface MoneyFare{ + public void charge(String c); +} diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" new file mode 100644 index 00000000..ebefb24a --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" @@ -0,0 +1,6 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public abstract class MotorVehicles { + public abstract void brake(String s); + +} diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" new file mode 100644 index 00000000..4e9207dc --- /dev/null +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" @@ -0,0 +1,18 @@ +package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; + +public class Taxi extends MotorVehicles implements MoneyFare,ControlTemperature { + @Override + public void charge(String c) { + System.out.println("出租车:" + c + "元/公里,起步价3公里"); + } + + @Override + public void brake(String s) { + System.out.println("出租车使用的刹车技术:" + s); + } + + @Override + public void controlAirTemperature(String t) { + System.out.println("出租车安装了" + t); + } +} -- Gitee From e83781e15bf72496ee050330a8813ebad3953500 Mon Sep 17 00:00:00 2001 From: LZQ <3165279696@qq.com> Date: Wed, 8 May 2024 19:39:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?0507=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bus.java" | 1 + .../ControlTemperature.java" | 2 +- .../Main.java" | 2 +- .../MoneyFare.java" | 2 +- .../MotorVehicles.java" | 2 +- .../Taxi.java" | 1 + 6 files changed, 6 insertions(+), 4 deletions(-) diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" index 591c15b2..b1b20e1f 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" @@ -11,4 +11,5 @@ public class Bus extends MotorVehicles implements MoneyFare{ System.out.println("公共汽车使用的刹车技术:" + s); } } +// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" index 30d22f24..a397782c 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" @@ -2,4 +2,4 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public interface ControlTemperature { public void controlAirTemperature(String t); -} +}// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" index 28781513..b2302053 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" @@ -11,4 +11,4 @@ public class Main { taxi.charge("1"); taxi.controlAirTemperature("嵌入式空调"); } -} +}/// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" index 705a9bdb..a2c4e2f7 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" @@ -2,4 +2,4 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public interface MoneyFare{ public void charge(String c); -} +}// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" index ebefb24a..216ad76d 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" @@ -1,6 +1,6 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public abstract class MotorVehicles { - public abstract void brake(String s); + public abstract void brake(String s); /// } diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" index 4e9207dc..d93d09bd 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" @@ -16,3 +16,4 @@ public class Taxi extends MotorVehicles implements MoneyFare,ControlTemperature System.out.println("出租车安装了" + t); } } +// \ No newline at end of file -- Gitee From e183a8f485427bfb8f03d7e6390ad4d4c215f23e Mon Sep 17 00:00:00 2001 From: LZQ <3165279696@qq.com> Date: Wed, 8 May 2024 19:41:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?0507=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bus.java" | 2 +- .../ControlTemperature.java" | 2 +- .../Main.java" | 2 +- .../MoneyFare.java" | 2 +- .../MotorVehicles.java" | 2 +- .../Taxi.java" | 3 +-- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" index b1b20e1f..faa70e47 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Bus.java" @@ -11,5 +11,5 @@ public class Bus extends MotorVehicles implements MoneyFare{ System.out.println("公共汽车使用的刹车技术:" + s); } } -// +///// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" index a397782c..6a4aeb4f 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/ControlTemperature.java" @@ -2,4 +2,4 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public interface ControlTemperature { public void controlAirTemperature(String t); -}// +}///// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" index b2302053..72391438 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" @@ -11,4 +11,4 @@ public class Main { taxi.charge("1"); taxi.controlAirTemperature("嵌入式空调"); } -}/// +}//////// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" index a2c4e2f7..b451cdc6 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MoneyFare.java" @@ -2,4 +2,4 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public interface MoneyFare{ public void charge(String c); -}// +}///// diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" index 216ad76d..61335ca7 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/MotorVehicles.java" @@ -1,6 +1,6 @@ package com.java.minxi.java_20240507.java_2301_刘志强_2344310107; public abstract class MotorVehicles { - public abstract void brake(String s); /// + public abstract void brake(String s); /////// } diff --git "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" index d93d09bd..f7e32daf 100644 --- "a/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" +++ "b/work/com/java/minxi/java_20240507/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Taxi.java" @@ -15,5 +15,4 @@ public class Taxi extends MotorVehicles implements MoneyFare,ControlTemperature public void controlAirTemperature(String t) { System.out.println("出租车安装了" + t); } -} -// \ No newline at end of file +}//////// -- Gitee From 7ec2a71c586b23210acdb0d80b703c372b439891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BF=97=E5=BC=BA?= <3165279696@qq.com> Date: Mon, 13 May 2024 19:34:42 +0800 Subject: [PATCH 5/5] 0513 --- .../Main.java" | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 "work/com/java/minxi/java_20240513/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" diff --git "a/work/com/java/minxi/java_20240513/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" "b/work/com/java/minxi/java_20240513/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" new file mode 100644 index 00000000..b4b3082c --- /dev/null +++ "b/work/com/java/minxi/java_20240513/java_2301_\345\210\230\345\277\227\345\274\272_2344310107/Main.java" @@ -0,0 +1,121 @@ +package com.java.minxi.java_20240513.java_2301_刘志强_2344310107; + +import java.util.ArrayList; +import java.util.LinkedList; + +public class Main { + + //创建和初始化 + public static void main(String[] args) { + + ArrayList array = new ArrayList(); + + array.add("1"); + array.add("2"); + array.add("3"); + array.add("4"); + array.add("5"); + + LinkedList linked = new LinkedList(); + + linked.add(1); + linked.add(2); + linked.add(3); + linked.add(4); + linked.add(5); + + System.out.println("array数据添加后:" + array); + System.out.println("linked数据添加后:" + linked); + + System.out.println("==================================================="); + +// 2.添加元素 + + ArrayList array1 = new ArrayList(); + array1.add("a"); + array1.add("b"); + array1.add("c"); + LinkedList linked1 = new LinkedList(); + linked1.add(1); + linked1.add(2); + linked1.add(3); + System.out.println("array1数据添加前" + array1); + System.out.println("linked1数据添加前" + linked1); + + array1.add(0, "A"); + linked1.addLast(4); + + System.out.println("array1数据添加后" + array1); + System.out.println("linked1数据添加后" + linked1); + + System.out.println("==================================================="); + +// 3.删除元素 + ArrayList array3 = new ArrayList(); + array3.add("1"); + array3.add("2"); + array3.add("3"); + System.out.println("array3数据添加前" + array3); + + LinkedList linked3 = new LinkedList(); + linked3.add("一"); + linked3.add("二"); + linked3.add("三"); + System.out.println("linked3数据添加前" + linked3); + + array3.remove(2); + linked3.removeLast(); + + System.out.println("array3数据删除后" + array3); + System.out.println("linked3数据删除后" + linked3); + + System.out.println("==================================================="); + +// 4.访问元素 + ArrayList array4 = new ArrayList(); + array4.add("A"); + array4.add("B"); + array4.add("C"); + array4.add("D"); + array4.add("E"); + System.out.println("array4的数据为" + array4); + + LinkedList linked4 = new LinkedList(); + linked4.add(1); + linked4.add(2); + linked4.add(3); + linked4.add(4); + linked4.add(5); + + System.out.println("linked4的数据为" + linked4); + + array4.get(3); + linked4.getLast(); + + System.out.println("==================================================="); + +// 5.修改元素 + ArrayList array5 = new ArrayList(); + array5.add(1); + array5.add(2); + array5.add(3); + System.out.println("array5的数据修改前为" + array5); + + LinkedList linked5 = new LinkedList(); + linked5.add("1"); + linked5.add("2"); + linked5.add("3"); + System.out.println("linked5的数据修改前为" + linked5); + + array5.set(1,"New Element"); + linked5.set(0,42); + + System.out.println("array5的数据修改后为" + array5); + System.out.println("linked5的数据修改后为" + linked5); + + System.out.println("==================================================="); + + + + } +} -- Gitee