ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
Structs对数据进行传递,同样采用的javabean方式。 数据大体是这样被传递的。 ![](https://box.kancloud.cn/dbf0f9962c9809794413c0b5985c37c9_244x708.png) ## 初始化私有变量 ``` package teacher; public class Save { private String username; private String password; private String sex; private String name; private String email; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } // 该execute方法将被自动调用, 方法的返回类型必须为String public String execute() { System.out.println("获取到用户名为:" + username); System.out.println("获取到姓名为:" + name); System.out.println("获取到性别为:" + sex); System.out.println("获取到邮箱为:" + email); System.out.println("获取到密码为:" + password); return "success"; // 返回字符串success } } ``` ### 测试 ![](https://box.kancloud.cn/6ec4f8b0ab8684e30e13c411054efcab_321x204.png) 查看控制台: ![](https://box.kancloud.cn/dc1dde364155f9a0c0ccf02754fa14fe_596x225.png) ## 作业 改变C层代码,以显示保存失败。