当前位置: 首页 > news >正文

简单的Java小项目

学生选课系统

在控制台输入输出信息:
在这里插入图片描述

在eclipse上面的超级简单文件结构:
在这里插入图片描述
Main.java

package experiment_4;import java.util.*;
import java.io.*;public class Main {public static List<Course> courseList = new ArrayList<>();public static List<Teacher> teacherList = new ArrayList<>();public static List<Student> studentList = new ArrayList<>();public static void main(String[] args) {loadData();Scanner scanner = new Scanner(System.in);while (true) {System.out.println("===== 欢迎使用学生选课系统 =====");System.out.print("请输入用户名(输入exit退出):");String username = scanner.nextLine();if (username.equals("exit")) {saveData();break;}System.out.print("请输入密码:");String password = scanner.nextLine();User user = null;if (username.equals("admin")) {user = new Admin(username, courseList, teacherList, studentList);} else {user = findUserByUsername(username);}if (user == null) {System.out.println("用户不存在!");continue;}if (!user.verifyPassword(password)) {System.out.println("密码错误!");continue;}user.operate();}scanner.close();}private static User findUserByUsername(String username) {for (Teacher teacher : teacherList) {if (teacher.getUsername().equals(username)) {return teacher;}}for (Student student : studentList) {if (student.getUsername().equals(username)) {return student;}}return null;}private static void loadData() {try (ObjectInputStream ois1 = new ObjectInputStream(new FileInputStream("C:\\Users\\86183\\Desktop\\courses.txt"));ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("C:\\Users\\86183\\Desktop\\teachers.txt"));ObjectInputStream ois3 = new ObjectInputStream(new FileInputStream("C:\\Users\\86183\\Desktop\\students.txt"))) {courseList = (List<Course>) ois1.readObject();teacherList = (List<Teacher>) ois2.readObject();studentList = (List<Student>) ois3.readObject();} catch (Exception e) {System.out.println("初次运行,未找到数据文件。");}}private static void saveData() {try (ObjectOutputStream oos1 = new ObjectOutputStream(new FileOutputStream("C:\\Users\\86183\\Desktop\\courses.txt"));ObjectOutputStream oos2 = new ObjectOutputStream(new FileOutputStream("C:\\Users\\86183\\Desktop\\teachers.txt"));ObjectOutputStream oos3 = new ObjectOutputStream(new FileOutputStream("C:\\Users\\86183\\Desktop\\students.txt"))) {oos1.writeObject(courseList);oos2.writeObject(teacherList);oos3.writeObject(studentList);System.out.println("数据已保存。");} catch (IOException e) {e.printStackTrace();}}
}

Admin.java

package experiment_4;import java.util.*;
import java.io.*;public class Admin extends User {private List<Course> courseList;private List<Teacher> teacherList;private List<Student> studentList;public Admin(String username, List<Course> courseList, List<Teacher> teacherList, List<Student> studentList) {super(username);this.courseList = courseList;this.teacherList = teacherList;this.studentList = studentList;}@Overridepublic void displayMenu() {System.out.println("===== 管理员菜单 =====");System.out.println("1. 添加课程");System.out.println("2. 删除课程");System.out.println("3. 按照选课人数排序");System.out.println("4. 显示课程清单");System.out.println("5. 修改授课教师");System.out.println("6. 显示学生列表");System.out.println("7. 显示教师列表");System.out.println("8. 恢复学生和教师初始密码");System.out.println("9. 添加老师和学生");System.out.println("10. 删除老师和学生");System.out.println("0. 退出");System.out.print("请选择操作:");}@Overridepublic void operate() {Scanner scanner = new Scanner(System.in);while (true) {displayMenu();int choice = scanner.nextInt();switch (choice) {case 1:addCourse();break;case 2:deleteCourse();break;case 3:sortCoursesByStudentNumber();break;case 4:displayCourseList();break;case 5:modifyCourseTeacher();break;case 6:displayStudentList();break;case 7:displayTeacherList();break;case 8:resetPasswords();break;case 9:addUser();break;case 10:deleteUser();break;case 0:System.out.println("退出管理员系统。");return;default:System.out.println("无效的选择,请重新输入。");}}}private void addCourse() {Scanner scanner = new Scanner(System.in);System.out.print("请输入课程ID:");String courseID = scanner.nextLine();System.out.print("请输入课程名称:");String courseName = scanner.nextLine();System.out.print("请输入授课教师用户名:");String teacherName = scanner.nextLine();Teacher teacher = findTeacherByUsername(teacherName);if (teacher == null) {System.out.println("教师不存在!");return;}System.out.print("课程类型(1.必修 2.选修):");int type = scanner.nextInt();if (type == 1) {Course course = new CompulsoryCourse(courseID, courseName, teacher);courseList.add(course);// 所有学生自动加入必修课for (Student student : studentList) {student.getCoursesEnrolled().add(course);course.incrementStudentNumber();}} else if (type == 2) {System.out.print("请输入选修课最大人数:");int maxStudents = scanner.nextInt();Course course = new ElectiveCourse(courseID, courseName, teacher, maxStudents);courseList.add(course);} else {System.out.println("无效的课程类型!");return;}teacher.getCoursesTaught().add(courseList.get(courseList.size() - 1));System.out.println("课程添加成功!");}private void deleteCourse() {Scanner scanner = new Scanner(System.in);System.out.print("请输入要删除的课程ID:");String courseID = scanner.nextLine();Course course = findCourseByID(courseID);if (course != null) {courseList.remove(course);// 从教师和学生的课程列表中删除该课程course.getTeacher().getCoursesTaught().remove(course);for (Student student : studentList) {student.getCoursesEnrolled().remove(course);}System.out.println("课程删除成功!");} else {System.out.println("课程不存在!");}}private void sortCoursesByStudentNumber() {Collections.sort(courseList, new Comparator<Course>() {@Overridepublic int compare(Course c1, Course c2) {return c2.getNumberOfStudents() - c1.getNumberOfStudents();}});System.out.println("课程已按照选课人数排序!");}private void displayCourseList() {System.out.println("===== 课程清单 =====");for (Course course : courseList) {System.out.println(course);}}private void modifyCourseTeacher() {Scanner scanner = new Scanner(System.in);System.out.print("请输入要修改的课程ID:");String courseID = scanner.nextLine();Course course = findCourseByID(courseID);if (course == null) {System.out.println("课程不存在!");return;}System.out.print("请输入新教师的用户名:");String teacherName = scanner.nextLine();Teacher newTeacher = findTeacherByUsername(teacherName);if (newTeacher == null) {System.out.println("教师不存在!");return;}// 更新教师信息course.getTeacher().getCoursesTaught().remove(course);course.setTeacher(newTeacher);newTeacher.getCoursesTaught().add(course);System.out.println("授课教师修改成功!");}private void displayStudentList() {System.out.println("===== 学生列表 =====");for (Student student : studentList) {System.out.println(student.getUsername());}}private void displayTeacherList() {System.out.println("===== 教师列表 =====");for (Teacher teacher : teacherList) {System.out.println(teacher.getUsername());}}private void resetPasswords() {for (Student student : studentList) {student.setPassword("123456");}for (Teacher teacher : teacherList) {teacher.setPassword("123456");}System.out.println("学生和教师密码已重置为初始密码!");}private void addUser() {Scanner scanner = new Scanner(System.in);System.out.print("添加对象(1.教师 2.学生):");int type = scanner.nextInt();scanner.nextLine(); // 消耗换行符System.out.print("请输入用户名:");String username = scanner.nextLine();if (type == 1) {Teacher teacher = new Teacher(username);teacherList.add(teacher);System.out.println("教师添加成功!");} else if (type == 2) {Student student = new Student(username);// 将学生加入所有必修课for (Course course : courseList) {if (course instanceof CompulsoryCourse) {student.getCoursesEnrolled().add(course);course.incrementStudentNumber();}}studentList.add(student);System.out.println("学生添加成功!");} else {System.out.println("无效的类型!");}}private void deleteUser() {Scanner scanner = new Scanner(System.in);System.out.print("删除对象(1.教师 2.学生):");int type = scanner.nextInt();scanner.nextLine(); // 消耗换行符System.out.print("请输入用户名:");String username = scanner.nextLine();if (type == 1) {Teacher teacher = findTeacherByUsername(username);if (teacher != null) {teacherList.remove(teacher);// 从课程中移除教师for (Course course : courseList) {if (course.getTeacher().equals(teacher)) {course.setTeacher(null);}}System.out.println("教师删除成功!");} else {System.out.println("教师不存在!");}} else if (type == 2) {Student student = findStudentByUsername(username);if (student != null) {studentList.remove(student);// 从课程中移除学生for (Course course : student.getCoursesEnrolled()) {course.decrementStudentNumber();}System.out.println("学生删除成功!");} else {System.out.println("学生不存在!");}} else {System.out.println("无效的类型!");}}private Teacher findTeacherByUsername(String username) {for (Teacher teacher : teacherList) {if (teacher.getUsername().equals(username)) {return teacher;}}return null;}private Student findStudentByUsername(String username) {for (Student student : studentList) {if (student.getUsername().equals(username)) {return student;}}return null;}private Course findCourseByID(String courseID) {for (Course course : courseList) {if (course.getCourseID().equals(courseID)) {return course;}}return null;}
}

CompulsoryCourse.java

package experiment_4;public class CompulsoryCourse extends Course {public CompulsoryCourse(String courseID, String courseName, Teacher teacher) {super(courseID, courseName, teacher);}@Overridepublic String toString() {return super.toString() + "(必修课)";}
}

Course.java

package experiment_4;import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;public class Course implements Serializable {protected String courseID;protected String courseName;protected Teacher teacher;protected int numberOfStudents;protected List<Student> enrolledStudents;public Course(String courseID, String courseName, Teacher teacher) {this.courseID = courseID;this.courseName = courseName;this.teacher = teacher;this.numberOfStudents = 0;this.enrolledStudents = new ArrayList<>();}public String getCourseID() {return courseID;}public Teacher getTeacher() {return teacher;}public void setTeacher(Teacher teacher) {this.teacher = teacher;}public int getNumberOfStudents() {return numberOfStudents;}public void incrementStudentNumber() {this.numberOfStudents++;}public void decrementStudentNumber() {this.numberOfStudents--;}public List<Student> getEnrolledStudents() {return enrolledStudents;}@Overridepublic String toString() {return "课程ID:" + courseID + ", 课程名称:" + courseName + ", 授课教师:" + teacher.getUsername() +", 选课人数:" + numberOfStudents;}
}

ElectiveCourse.java

package experiment_4;public class ElectiveCourse extends Course {private int maxStudents;public ElectiveCourse(String courseID, String courseName, Teacher teacher, int maxStudents) {super(courseID, courseName, teacher);this.maxStudents = maxStudents;}public int getMaxStudents() {return maxStudents;}@Overridepublic String toString() {return super.toString() + ", 最大选课人数:" + maxStudents + "(选修课)";}
}

Student.java

package experiment_4;import java.util.*;public class Student extends User {private List<Course> coursesEnrolled;public Student(String username) {super(username);this.coursesEnrolled = new ArrayList<>();}@Overridepublic void displayMenu() {System.out.println("===== 学生菜单 =====");System.out.println("1. 修改登录密码");System.out.println("2. 查看自己所上课程");System.out.println("3. 选修课选课");System.out.println("0. 退出");System.out.print("请选择操作:");}@Overridepublic void operate() {Scanner scanner = new Scanner(System.in);while (true) {displayMenu();int choice = scanner.nextInt();scanner.nextLine(); // 消耗换行符switch (choice) {case 1:changePassword(scanner); // 传递 Scanner 对象break;case 2:viewCoursesEnrolled();break;case 3:selectElectiveCourse();break;case 0:System.out.println("退出学生系统。");return;default:System.out.println("无效的选择,请重新输入。");}}}public void changePassword(Scanner scanner) { // 接受 Scanner 作为参数System.out.print("请输入新密码:");String newPassword = scanner.nextLine();super.changePassword(newPassword); // 调用父类的方法}public void viewCoursesEnrolled() {System.out.println("===== 已选课程列表 =====");for (Course course : coursesEnrolled) {System.out.println(course);}}public void selectElectiveCourse() {Scanner scanner = new Scanner(System.in);System.out.print("请输入选修课ID:");String courseID = scanner.nextLine();Course course = findCourseByID(courseID);if (course == null) {System.out.println("课程不存在!");return;}if (!(course instanceof ElectiveCourse)) {System.out.println("这不是一门选修课!");return;}ElectiveCourse electiveCourse = (ElectiveCourse) course;if (electiveCourse.getNumberOfStudents() >= electiveCourse.getMaxStudents()) {System.out.println("选课人数已满!");return;}if (coursesEnrolled.contains(course)) {System.out.println("您已选过此课程!");return;}coursesEnrolled.add(course);course.incrementStudentNumber();System.out.println("选课成功!");}private Course findCourseByID(String courseID) {for (Course course : Main.courseList) {if (course.getCourseID().equals(courseID)) {return course;}}return null;}public List<Course> getCoursesEnrolled() {return coursesEnrolled;}
}

Teacher.java

package experiment_4;import java.util.*;public class Student extends User {private List<Course> coursesEnrolled;public Student(String username) {super(username);this.coursesEnrolled = new ArrayList<>();}@Overridepublic void displayMenu() {System.out.println("===== 学生菜单 =====");System.out.println("1. 修改登录密码");System.out.println("2. 查看自己所上课程");System.out.println("3. 选修课选课");System.out.println("0. 退出");System.out.print("请选择操作:");}@Overridepublic void operate() {Scanner scanner = new Scanner(System.in);while (true) {displayMenu();int choice = scanner.nextInt();scanner.nextLine(); // 消耗换行符switch (choice) {case 1:changePassword(scanner); // 传递 Scanner 对象break;case 2:viewCoursesEnrolled();break;case 3:selectElectiveCourse();break;case 0:System.out.println("退出学生系统。");return;default:System.out.println("无效的选择,请重新输入。");}}}public void changePassword(Scanner scanner) { // 接受 Scanner 作为参数System.out.print("请输入新密码:");String newPassword = scanner.nextLine();super.changePassword(newPassword); // 调用父类的方法}public void viewCoursesEnrolled() {System.out.println("===== 已选课程列表 =====");for (Course course : coursesEnrolled) {System.out.println(course);}}public void selectElectiveCourse() {Scanner scanner = new Scanner(System.in);System.out.print("请输入选修课ID:");String courseID = scanner.nextLine();Course course = findCourseByID(courseID);if (course == null) {System.out.println("课程不存在!");return;}if (!(course instanceof ElectiveCourse)) {System.out.println("这不是一门选修课!");return;}ElectiveCourse electiveCourse = (ElectiveCourse) course;if (electiveCourse.getNumberOfStudents() >= electiveCourse.getMaxStudents()) {System.out.println("选课人数已满!");return;}if (coursesEnrolled.contains(course)) {System.out.println("您已选过此课程!");return;}coursesEnrolled.add(course);course.incrementStudentNumber();System.out.println("选课成功!");}private Course findCourseByID(String courseID) {for (Course course : Main.courseList) {if (course.getCourseID().equals(courseID)) {return course;}}return null;}public List<Course> getCoursesEnrolled() {return coursesEnrolled;}
}

User.java

package experiment_4;import java.io.Serializable;//允许类的对象可以被序列化public abstract class User implements Serializable {protected String username;protected String password;//在定义该成员的类内部、同一包中的其他类、以及任何子类中(无论子类是否在同一个包中)都可以访问。public User(String username) {this.username = username;this.password = "123456"; // 初始密码}public String getUsername() {return username;}public void setPassword(String newPassword) {//设置密码this.password = newPassword;}public boolean verifyPassword(String password) {//验证密码return this.password.equals(password);}public void changePassword(String newPassword) {//修改密码this.password = newPassword;System.out.println("密码修改成功!");}public abstract void displayMenu();public abstract void operate();
}

无需用到模块化module-info.java

/*** */
/*** */
module experiment_4 {
}

相关文章:

简单的Java小项目

学生选课系统 在控制台输入输出信息&#xff1a; 在eclipse上面的超级简单文件结构&#xff1a; Main.java package experiment_4;import java.util.*; import java.io.*;public class Main {public static List<Course> courseList new ArrayList<>();publi…...

使用layui的table提示Could not parse as expression(踩坑记录)

踩坑记录 报错图如下 原因&#xff1a; 原来代码是下图这样 上下俩中括号都是连在一起的&#xff0c;可能导致解析问题 改成如下图这样 重新启动项目&#xff0c;运行正常&#xff01;...

区块链共识机制详解

一.共识机制简介 在区块链的交流和学习中&#xff0c;「共识算法」是一个很频繁被提起的词汇&#xff0c;正是因为共识算法的存在&#xff0c;区块链的可信性才能被保证。 1.1 为什么需要共识机制&#xff1f; 所谓共识&#xff0c;就是多个人达成一致的意思。我们生活中充满…...

【Excel】单元格分列

目录 分列&#xff08;新手友好&#xff09; 1. 选中需要分列的单元格后&#xff0c;选择 【数据】选项卡下的【分列】功能。 2. 按照分列向导提示选择适合的分列方式。 3. 分好就是这个样子 智能分列&#xff08;进阶&#xff09; 高级分列 Tips&#xff1a; 新手推荐基…...

【含开题报告+文档+PPT+源码】基于微信小程序的旅游论坛系统的设计与实现

开题报告 近年来&#xff0c;随着互联网技术的迅猛发展&#xff0c;人们的生活方式、消费习惯以及信息交流方式都发生了深刻的变化。旅游业作为国民经济的重要组成部分&#xff0c;其信息化、网络化的发展趋势也日益明显。旅游论坛作为旅游信息交流和分享的重要平台&#xff0…...

微软 Phi-4:小型模型的推理能力大突破

在人工智能领域&#xff0c;语言模型的发展日新月异。微软作为行业的重要参与者&#xff0c;一直致力于推动语言模型技术的进步。近日&#xff0c;微软推出了最新的小型语言模型 Phi-4&#xff0c;这款模型以其卓越的复杂推理能力和在数学领域的出色表现&#xff0c;引起了广泛…...

操作系统课后习题2.2节

操作系统课后习题2.2节 第1题 CPU的效率指的是CPU的执行速度&#xff0c;这个是由CPU的设计和它的硬件来决定的&#xff0c;具体的调度算法是不能提高CPU的效率的&#xff1b; 第3题 互斥性&#xff1a; 指的是进程之间的同步互斥关系&#xff0c;进程是一个动态的过程&#…...

[小白系列]安装sentence-transformers

python环境为3.13.1执行 pip install sentence-transformers 总是报以下问题 ERROR: Cannot install sentence-transformers0.1.0, sentence-transformers0.2.0, sentence-transformers0.2.1, sentence-transformers0.2.2, sentence-transformers0.2.3, sentence-transformers…...

Python字符串format方法全面解析

在Python中&#xff0c;format方法是一种用于格式化字符串的强大工具。它允许你构建一个字符串&#xff0c;其中包含一些“占位符”&#xff0c;这些占位符将被format方法的参数替换。以下是对format方法用法的详细解释&#xff1a; 基本用法 format方法的基本语法如下&#…...

【Reading Notes】Favorite Articles from 2024

文章目录 1、January2、February3、March4、April5、May6、June7、July8、August9、September10、October11、November12、December 1、January 2、February 3、March Sora外部测试翻车了&#xff01;3个视频都有Bug&#xff08; 2024年03月01日&#xff09; 不仔细看还真看不…...

Python爬虫之Scrapy框架基础入门

Scrapy 是一个用于Python的开源网络爬虫框架&#xff0c;它为编写网络爬虫来抓取网站数据并提取结构化信息提供了一种高效的方法。Scrapy可以用于各种目的的数据抓取&#xff0c;如数据挖掘、监控和自动化测试等。 【1】安装 pip install scrapy安装成功如下所示&#xff1a;…...

spring cloud contract mq测试

对于spring cloud contract的环境配置和部署&#xff0c;请看我之前的文章。 一 生产者测试 测试生产者是否发送出消息&#xff0c;并测试消息内容是否正确。 编写测试合同 测试基类&#xff08;ContractTestBase&#xff09;上面要添加下面注解 SpringBootTest AutoConfig…...

Axure原型设计技巧与经验分享

AxureRP作为一款强大的原型设计工具&#xff0c;凭借其丰富的交互设计能力和高保真度的模拟效果&#xff0c;赢得了众多UI/UX设计师、产品经理及开发人员的青睐。本文将分享一些Axure原型设计的实用技巧与设计经验&#xff0c;帮助读者提升工作效率&#xff0c;打造更加流畅、用…...

计算机网络之王道考研读书笔记-1

第 1 章 计算机网络体系结构 1.1 计算机网络概述 1.1.1 计算机网络概念 internet(互连网)&#xff1a;泛指由多个计算机网络互连而成的计算机网络。这些网络之间可使用任意通信协议。 Internet(互联网或因特网)&#xff1a;指当前全球最大的、开放的、由众多网络和路由器互连…...

服务器限制某个端口只允许特定IP访问(处理第三方依赖漏洞)

最近项目部署之后&#xff0c;有些客户开始进行系统系统漏洞扫描&#xff0c;其中出现问题多的一个就是我们项目所依赖的Elasticsearch&#xff08;es检索服务&#xff09;&#xff0c;很容易就被扫出来各种高危漏洞&#xff0c;而且这些漏洞我们在处理起来是很棘手的&#xff…...

JavaScript--原型与原型链

在JavaScript中&#xff0c;原型&#xff08;prototype&#xff09;是一个非常重要且独特的概念&#xff0c;它在对象创建和继承方面发挥着关键作用。理解原型及其相关的机制有助于更好地理解JavaScript的对象模型&#xff0c;以及如何设计和使用对象和继承。 JavaScript–原型…...

hive—常用的日期函数

目录 1、current_date 当前日期 2、now() 或 current_timestamp() 当前时间 3、datediff(endDate, startDate) 计算日期相差天数 4、months_between(endDate, startDate) 日期相差月数 5、date_add(startDate, numDays) 日期加N天 6、date_sub(startDate, numDays) 日期减…...

HTML零基础入门教学

目录 一. HTML语言 二. HTML结构 三. HTML文件基本结构 四. 准备开发环境 五. 快速生成代码框架 六. HTML常见标签 6.1 注释标签 6.2 标题标签&#xff1a;h1-h6 6.3 段落标签&#xff1a;p 6.4 换行标签&#xff1a;br 6.5 格式化标签 6.6 图片标签&a…...

vue3 父组件调用子组件 el-drawer 抽屉

之前 Vue3 只停留在理论&#xff0c;现在项目重构&#xff0c;刚好可以系统的实战一下&#xff0c;下面是封装了一个抽屉表单组件&#xff0c;直接在父组件中通过调用子组件的方法打开抽屉&#xff1a; 父组件&#xff1a; <template><div id"app"><…...

Java中常用算法之选择排序算法

一.选择排序&#xff08;Selection Sort&#xff09;是一种简单直观的排序算法。它的工作原理是每次从未排序部分选择最小&#xff08;或最大&#xff09;的元素&#xff0c;并将其放到已排序部分的末尾。以下是用Java实现选择排序的代码及其详细讲解。 二.选择排序代码 publ…...

idea大量爆红问题解决

问题描述 在学习和工作中&#xff0c;idea是程序员不可缺少的一个工具&#xff0c;但是突然在有些时候就会出现大量爆红的问题&#xff0c;发现无法跳转&#xff0c;无论是关机重启或者是替换root都无法解决 就是如上所展示的问题&#xff0c;但是程序依然可以启动。 问题解决…...

【WiFi帧结构】

文章目录 帧结构MAC头部管理帧 帧结构 Wi-Fi的帧分为三部分组成&#xff1a;MAC头部frame bodyFCS&#xff0c;其中MAC是固定格式的&#xff0c;frame body是可变长度。 MAC头部有frame control&#xff0c;duration&#xff0c;address1&#xff0c;address2&#xff0c;addre…...

JavaScript 中的 ES|QL:利用 Apache Arrow 工具

作者&#xff1a;来自 Elastic Jeffrey Rengifo 学习如何将 ES|QL 与 JavaScript 的 Apache Arrow 客户端工具一起使用。 想获得 Elastic 认证吗&#xff1f;了解下一期 Elasticsearch Engineer 培训的时间吧&#xff01; Elasticsearch 拥有众多新功能&#xff0c;助你为自己…...

23-Oracle 23 ai 区块链表(Blockchain Table)

小伙伴有没有在金融强合规的领域中遇见&#xff0c;必须要保持数据不可变&#xff0c;管理员都无法修改和留痕的要求。比如医疗的电子病历中&#xff0c;影像检查检验结果不可篡改行的&#xff0c;药品追溯过程中数据只可插入无法删除的特性需求&#xff1b;登录日志、修改日志…...

JVM垃圾回收机制全解析

Java虚拟机&#xff08;JVM&#xff09;中的垃圾收集器&#xff08;Garbage Collector&#xff0c;简称GC&#xff09;是用于自动管理内存的机制。它负责识别和清除不再被程序使用的对象&#xff0c;从而释放内存空间&#xff0c;避免内存泄漏和内存溢出等问题。垃圾收集器在Ja…...

P3 QT项目----记事本(3.8)

3.8 记事本项目总结 项目源码 1.main.cpp #include "widget.h" #include <QApplication> int main(int argc, char *argv[]) {QApplication a(argc, argv);Widget w;w.show();return a.exec(); } 2.widget.cpp #include "widget.h" #include &q…...

【Go】3、Go语言进阶与依赖管理

前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课&#xff0c;做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程&#xff0c;它的核心机制是 Goroutine 协程、Channel 通道&#xff0c;并基于CSP&#xff08;Communicating Sequential Processes&#xff0…...

【HTML-16】深入理解HTML中的块元素与行内元素

HTML元素根据其显示特性可以分为两大类&#xff1a;块元素(Block-level Elements)和行内元素(Inline Elements)。理解这两者的区别对于构建良好的网页布局至关重要。本文将全面解析这两种元素的特性、区别以及实际应用场景。 1. 块元素(Block-level Elements) 1.1 基本特性 …...

用docker来安装部署freeswitch记录

今天刚才测试一个callcenter的项目&#xff0c;所以尝试安装freeswitch 1、使用轩辕镜像 - 中国开发者首选的专业 Docker 镜像加速服务平台 编辑下面/etc/docker/daemon.json文件为 {"registry-mirrors": ["https://docker.xuanyuan.me"] }同时可以进入轩…...

OpenLayers 分屏对比(地图联动)

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 地图分屏对比在WebGIS开发中是很常见的功能&#xff0c;和卷帘图层不一样的是&#xff0c;分屏对比是在各个地图中添加相同或者不同的图层进行对比查看。…...