Advertisement
KuoHsiangYu

測試Java程式字元與整數的轉換

Jul 3rd, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. package com.ch01;
  2.  
  3. public class TestJava1 {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         String str = "這是一個測試字串";
  8.         System.out.println(str.indexOf('測'));
  9.         System.out.println(str.indexOf('空'));
  10.         char ch1 = '字';
  11.         System.out.printf("a. ch1 -> %d\n", (int) ch1);
  12.         int in1 = 23383;
  13.         System.out.printf("b. in1 -> %c\n", (char) in1);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement