1. 程式人生 > >實現從命令列引數輸入兩個字串型別的數值,並計算輸出兩個數值的和。 [必做題]

實現從命令列引數輸入兩個字串型別的數值,並計算輸出兩個數值的和。 [必做題]

import java.io.UnsupportedEncodingException;
import java.util.Scanner;

public class ZiFuChuanHe {

	public static void main(String[] args) throws UnsupportedEncodingException {
		Scanner s=new Scanner(System.in);
		System.out.println("請輸入第一個字元");
		  String t=s.next();
		  byte []bytes =t.getBytes();
		  int U= bytes[0];
		  System.out.println("請輸入第二個字元");
		  String t1=s.next();
		  byte []bytes1 =t1.getBytes();
		  int U1= bytes1[0];
		  System.out.println(bytes[0]);
		  System.out.println(bytes1[0]);
		 System.out.println(U+U1);

	}

}