代码链接:https://pan.baidu.com/s/1ty4CzDEX1_l0XbpzY8rs8g?pwd=iktj
提取码:iktj
为什么我在idea可以正确输出中文,但是在vscode输出的时候是个乱码的问号,我在后台的设置已经把编码变成utf8了,但还是这样,我应该在vscode怎么设置才能变成像idea那样?(代码是b站上面黑马程序员的java教程上面的感觉没什么逻辑上的问题,就是不知道为什么vscode要怎么配置环境才能让我插入学生信息的让学生信息的中文姓名显示出来,而不是❓)我真的不懂怎么 配vscode这个环境😭
不想打开链接的话可以直接看一下代码:
学生类代码:
public class Student {
private String name;
private String id;
private int age;
private String homeAddress;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getHomeAddress() {
return homeAddress;
}
public void setHomeAddress(String homeAddress) {
this.homeAddress = homeAddress;
}
public Student(String name, String id, int age, String homeAddress) {
this.name = name;
this.id = id;
this.age = age;
this.homeAddress = homeAddress;
}
public Student(){
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class StudentSystem {
public static void main(String[] args) {
// 添加一个列表用于存储对象
ArrayList<Student> list = new ArrayList<>();
loop:while (true) {
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("请输入你的选择:");
Scanner sc = new Scanner(System.in);
String choose = sc.next();
switch (choose) {
case "1" -> addStudent(list);
case "2" -> deleteStudent(list);
case "3" -> updateStudent(list);
case "4" -> queryStudent(list);
case "5" -> {
System.out.println("退出");
break loop; // 把循环设计一个标号,这样就能退出整个循环了,或者用system.exit(0)停止虚拟机使用,也就是点击右上角的❌的效果
}
default -> System.out.println("没有这个选项");
}
}
}
public static void addStudent( ArrayList<Student> list){
// 先来一个空参构造函数,用来东西进去
Student s = new Student();
Scanner sc = new Scanner(System.in);
System.out.println("请输入学生的id:");
String id = sc.next();
s.setId(id);
System.out.println("请输入学生的姓名:");
String name = sc.next();
s.setName(name);
System.out.println("请输入学生的年龄:");
int age = sc.nextInt();
s.setAge(age);
System.out.println("请输入学生的家庭住址:");
String homeAddress = sc.next();
s.setHomeAddress(homeAddress);
// 把学生对象添加到集合中
list.add(s);
}
public static void deleteStudent( ArrayList<Student> list){
System.out.println("删除学生");
}
public static void updateStudent( ArrayList<Student> list){
System.out.println("修改学生");
}
public static void queryStudent( ArrayList<Student> list){
if(list.size() == 0){
System.ou