public class Exercise { public static void main(String[] args) { print("我as我hias暗示", 6); } private static void print(String s, int count) { byte[] arr = s.getBytes();// 获得字节数组 count = isCnBegin(arr, count - 1) ? count - 1 :count; System.out.println(new String(arr, 0, count)); } private static boolean isCnBegin(byte[] arr, int index) { // TODO Auto-generated method stub boolean b = false; for (int i = 0; i <= index; i++) b = arr[i] < 0 && !b; return b; }}