ตรวจสอบความปลอดภัย
ลองตรวจสอบว่าเว็บไซต์ที่ต้องการเข้าถึงนั้นปลอดภัยหรือไม่ เว็บไซต์ที่ปลอดภัยจะขึ้นต้นด้วย https:// ส่วนเว็บไซต์ที่ไม่ปลอดภัยจะขึ้นต้นด้วย http:// (สังเกตว่าไม่มีตัว s)
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Java ระดับกลาง
คำแนะนำการฝึกหัด
- กำหนด index ที่ถูกต้องของอักขระ
's'ใน Stringurlให้กับตัวแปรcharPosition - ใช้เมธอดของ String ที่เหมาะสมกับ
urlเพื่อดึงอักขระที่ตำแหน่งนั้น แล้วพิมพ์ผลลัพธ์ออกมา
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
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));
}
}