慕田峪9158850
2019-08-03 10:03:26
當(dāng)我試圖編譯我的Java代碼時(shí),為什么我會(huì)得到“異常;必須被捕獲或聲明為被拋出”?考慮: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);
}
}我得到了一個(gè)未報(bào)告的例外:java.lang.Exception; must be caught or declared to be thrownbyte[] encrypted = encrypt(concatURL);以及:.java:109: missing return statement如何解決這些問(wèn)題?
3 回答

眼眸繁星
TA貢獻(xiàn)1873條經(jīng)驗(yàn) 獲得超9個(gè)贊
異常;必須捕獲或聲明為拋出字節(jié)[]加密=加密(串聯(lián)URL);
encrypt
actionPerformed
你可以移除 throws Exception
從你的 encrypt
方法和 實(shí)際手柄
內(nèi)部異常 encrypt
.可以從 encrypt
加上 throws Exception
的異常處理塊 actionPerformed
方法。
encrypt
encrypt
添加回答
舉報(bào)
0/150
提交
取消