
正文
java编写一段代码 java代码怎么编写
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
给段最简单的java代码 让我新手看一下
最简单的java代码肯定就是这个了,如下:
public class MyFirstApp
{
public static void main(String[] args)
{
System.out.print("Hello world");
}
}
“hello world”就是应该是所有学java的新手看的第一个代码了。如果是零基础的新手朋友们可以来我们的java实验班试听,有免费的试听课程帮助学习java必备基础知识,有助教老师为零基础的人提供个人学习方案,学习完成后有考评团进行专业测试,帮助测评学员是否适合继续学习java,15天内免费帮助来报名体验实验班的新手快速入门java,更好的学习java!
相关问答
Q1: java写一个自动程序开始先怎么写
使用Eclipse编写自己的第一个Java代码。
编写如下:
1、首先打开自己安装的Eclipse软件。
2、然后选择File-New-JavaProject。
3、然后找到工程打开,右击src选择-New-Class。
4、填入类名,选择下面的publicstaticvoidmain(String[]args)。
5、然后写入代码publicclassDemo{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubSystem.out.println(HelloWorld)。
6、点击上面的运行按钮,点击确认,可以看到代码运行结果。
Q2: 如何用java写这段代码?
import java.security.InvalidKeyException;import java.security.NoSuchAlgorithmException;import javax.crypto.BadPaddingException;import javax.crypto.Cipher;import javax.crypto.IllegalBlockSizeException;import javax.crypto.KeyGenerator;import javax.crypto.NoSuchPaddingException;import javax.crypto.SecretKey;public class JEncrytion{
public static void main(String[] argv) {
try{ KeyGenerator keygenerator = KeyGenerator.getInstance("DES"); SecretKey myDesKey = keygenerator.generateKey();
Cipher desCipher; // Create the cipher
desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
// Initialize the cipher for encryption
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey); //sensitive information
byte[] text = "No body can see me".getBytes();
System.out.println("Text [Byte Format] : " + text);
System.out.println("Text : " + new String(text));
// Encrypt the text
byte[] textEncrypted = desCipher.doFinal(text);
System.out.println("Text Encryted : " + textEncrypted);
// Initialize the same cipher for decryption
desCipher.init(Cipher.DECRYPT_MODE, myDesKey); // Decrypt the text
byte[] textDecrypted = desCipher.doFinal(textEncrypted);
System.out.println("Text Decryted : " + new String(textDecrypted));
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BadPaddingException e){
e.printStackTrace();
}
}
}
java编写一段代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java代码怎么编写、java编写一段代码的信息别忘了在本站进行查找喔。







