当我试图编译我的Java代码时,为什么我会得到“异常;必须被捕获或声明为被抛出”?考虑:import java.awt.*;import javax.swing.*;import java.awt.event.*;import javax.crypto.*;import javax.crypto.spec.*;import java.security.*;
import java.io.*;public class EncryptURL extends JApplet implements ActionListener {
Container content;
JTextField userName = new JTextField();
JTextField firstName = new JTextField();
JTextField lastName = new JTextField();
JTextField email = new JTextField();
JTextField phone = new JTextField();
JTextField heartbeatID = new JTextField();
JTextField regionCode = new JTextField();
JTextField retRegionCode = new JTextField();
JTextField encryptedTextField = new JTextField();
JPanel finishPanel = new JPanel();
public void init() {
//setTitle("Book - E Project");
setSize(800, 600);
content = getContentPane();
content.setBackground(Color.yellow);
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
JButton submit = new JButton("Submit");
content.add(new JLabel("User Name"));
content.add(userName);
content.add(new JLabel("First Name"));
content.add(firstName);
content.add(new JLabel("Last Name"));
content.add(lastName);
content.add(new JLabel("Email"));
content.add(email);
content.add(new JLabel("Phone"));
content.add(phone);
content.add(new JLabel("HeartBeatID"));
content.add(heartbeatID);
content.add(new JLabel("Region Code"));
content.add(regionCode);
content.add(new JLabel("RetRegionCode"));
content.add(retRegionCode);
content.add(submit);
submit.addActionListener(this);
}
}我得到了一个未报告的例外:java.lang.Exception; must be caught or declared to be thrownbyte[] encrypted = encrypt(concatURL);以及:.java:109: missing return statement如何解决这些问题?
3 回答
眼眸繁星
TA贡献1873条经验 获得超9个赞
异常;必须捕获或声明为抛出字节[]加密=加密(串联URL);
encrypt
actionPerformed
你可以移除 throws Exception
从你的 encrypt
方法和 实际手柄
内部异常 encrypt
.可以从 encrypt
加上 throws Exception
的异常处理块 actionPerformed
方法。
encrypt
encrypt
添加回答
举报
0/150
提交
取消