Created
January 21, 2019 13:25
-
-
Save jkasun/99af0f57ec9bfffc73146b35ea03a2a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
private int age; | |
public int getAge() { | |
return this.age; | |
} | |
public void setAge(int age) { | |
if (age < 0 || age > 200) { | |
throw new IllegalArgumentException("Invalid age"); | |
} | |
this.age = age; | |
} | |
} | |
public class HelloWorld{ | |
public static void main(String []args){ | |
Person p = new Person(); | |
p.setAge(-10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment