安全性檢查
你想確認要造訪的網站是否安全。所有試圖提供安全連線的網站都會以 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));
}
}