⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise7_19.java

📁 java程序设计 机械工业出版社 书籍代码
💻 JAVA
字号:
// Exercise7_19.java: Write a program that passes a string as a
// command-line argument and displays the number of uppercase
// letters in the string.
public class Exercise7_19 {
  public static void main(String[] args) {
    // Check command-line arguments
    if (args.length != 1) {
      System.out.println(
        "Usage: java Exercise7_19 string");
      System.exit(0);
    }

    String s = args[0];
    int total = 0;

    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
        total++;
    }

    System.out.println("The number of uppercase letters is " +
      total);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -