主函數(shù)
public static void main(String[]args){
System.out.println(“”);
System.err.println(“”);
}
輸出輸入
import java.util.Scanner;
Scanner scanner=new Scanner(System.in);
String line =scanner.next();
輸出流
PrintStream out = System.out;
PrintStream ps=new PrintStream("log.txt");
? ? ? ? ? ? System.setOut(ps);
? ? ? ? ? ? System.setOut(out);
出錯(cuò)
? try{
? }catch (FileNotFoundException e) {
?????????? e.printStackTrace();
???????}
加密
public class Examplemiyao {
? public static void main(String[] args) {
? System.out.println("請(qǐng)輸入一個(gè)英文字符串或解密字符串");
? Scanner scan = new Scanner(System.in);
? String password = scan.nextLine();
? char[] array = password.toCharArray();
? for (int i = 0; i < array.length; i++) {
? ? array[i] =? array[i];
? ? ? ? ? ? //array[i] = (char) (array[i] ^ 20000);
? ? ? ? }
? ? ? ? System.out.println("加密或解密結(jié)果如下:");
? ? ? ? System.err.println(new String(array));
? ? }
}
判斷奇偶數(shù)
long number = scan.nextLong();
String check = (number % 2 == 0) ? "這個(gè)數(shù)字是:偶數(shù)" : "這個(gè)數(shù)字是:奇數(shù)";