1. Create a java project and run it
1. First open Eclipse IDE
2. Create a project
Click File—>New—>Project in the upper left corner, so that you can create a new Java project. In other words, in Eclipse, our Java projects will be stored in the workspace namespace, and multiple Project items can be stored in one namespace.
3. After selecting Project, you will enter the following interface, select Java—>Java Project, and then click Next
4. Name the project here, do not use Chinese naming. In the following Module, please do not check it for the time being Create module-info.java file
, because we will not be involved in this modular mechanism for the time being.
5. Click Next to enter here
6. Click Finish, and then choose: Open Perspective or No can be used
7. In this way, a Java project is created in Eclipse, and then the Java class needs to be created in the src directory
8. Create Java class: right-click the src directory, click New—>Class
9, set the class name and modifier here, and then click the default Finish
10, write a java program
11, run the project: right click, select Run As—>Java Application
or Click the small green triangle
12. See the running results in the Console window
Remarks: If you do not see the Console window in the main interface, you can select the menu Window—>Show View—>Console to display it.
Two, Eclipse code formatting
1. Open the program and select the code to be formatted.
2. Click the Source menu on the menu bar.
3. Click the Format option on the drop-down menu.
4. The code has been formatted
Source code:
package TestDemo;
import java.util.Scanner;
public class Cipher {
private static int[] enc_key = {
6, 3, 0, 4, 5, 1, 2 }; // 加密密钥
private static int[] dec_key = {
2, 5, 6, 1, 3, 4, 0 }; // 解密密钥
public static void main(String[] args) {
char[][] m = new char[2][7];
char[][] c = new char[2][7];
char[][] dec_m = new char[2][7];
System.out.println("请输入两行7个英文字符的明文:");
try (Scanner scanner = new Scanner(System.in)) {
m[0] = scanner.nextLine().toCharArray();
m[1] = scanner.nextLine().toCharArray();
for (int i = 0; i < 7; i++) {
c[0][enc_key[i]] = m[0][i];
c[1][enc_key[i]] = m[1][i];
}
for (int i = 0; i < 7; i++) {
dec_m[0][dec_key[i]] = c[0][i];
dec_m[1][dec_key[i]] = c[1][i];
}
System.out.println("您输入的原始明文为:");
System.out.println(m[0]);
System.out.println(m[1]);
System.out.println("加密结果为:");
System.out.println(c[0]);
System.out.println(c[1]);
System.out.println("解密结果为:");
System.out.println(dec_m[0]);
System.out.println(dec_m[1]);
} catch (Exception e) {
System.err.println(e);
}
}
}
3. Delete items
1. If you don’t want an item, you can delete it directly. Select the item—>right click—>Delete.
2. If you want to delete this item completely from the computer, you can check the check box below. Otherwise, it is just removed from the Eclipse directory and will not be completely deleted.