Lesson 15 - Activity 4 - Can you throw your own exception?

Time: 15 minutes

Purpose: This activity helps you get familiar with throwing exceptions

Introduction: You’re had experience catching exceptions, learn to throw them as well

Task: Write a method which takes in a string and throws an exception IllegalArgumentException if the string contains the word “admin”.

String.contains(“admin”) method returns true if a string contains “admin”.