gpt4 book ai didi

java - token ";"上的语法错误,{ 应在此 token 之后

转载 作者:搜寻专家 更新时间:2023-11-01 03:57:59 24 4
gpt4 key购买 nike

为什么这一行有语法错误(如下所示)

package org.temp2.cod1;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.io.*;

public class Code1 {

byte[] plaintext = new byte[32]; // <<<<<<<<<<<<<<<<<<<<<<<<<< syntax error
for (int i = 0; i < 32; i++) {
plaintext[i] = (byte) (i % 16);
}

byte[] key = new byte[16];
SecureRandom r = new SecureRandom();
r.nextBytes(key);

Cipher c = Cipher.getInstance("AES");
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.ENCRYPT_MODE, k);
byte[] encryptedData = c.doFinal(plaintext);
}
}

最佳答案

您忘记了入口点方法声明。尝试添加:

public static void main(String[] args) {

在出现错误的行之前。

关于java - token ";"上的语法错误,{ 应在此 token 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1755259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com