始める無料で始める

セキュリティチェック

アクセスしようとしているサイトが安全かどうかを確認したいとします。セキュアなサイトはすべて https:// から始まります。そうでないものは http:// から始まります(s がないことに注意してください)。

この演習はコースの一部です

中級 Java

コースを見る

演習の手順

  • 文字列 url の中で、文字 's' の正しいインデックスを変数 charPosition に代入します。
  • url 文字列に適切な String メソッドを使って、その位置の文字を取り出し、出力してください。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

class SecurityChecker {
  public static void main(String[] args) {
    String url = "https://www.datacamp.com";
    // Enter the right position to retrieve the 's' of the above url
    int charPosition = ____;

    System.out.println("s means secure : ");
    // Enter the correct method on url to find the security character
    System.out.println(url.____(charPosition));
  }
}
コードを編集して実行