返回列表 發帖

printf() 函式 (二)

本帖最後由 tonyh 於 2015-3-28 16:28 編輯

printf()函式輸出練習:
%d 整數
%s 字串
%S 轉換為大寫字母的字串

  1. public class ch66
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         String str1="dog";
  6.         String str2="cat";
  7.         int a=3, b=5;
  8.         System.out.printf("There are %d %ss and %d %Ss.",a,str1,b,str2);
  9.     }
  10. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

返回列表