Skip to content

Instantly share code, notes, and snippets.

@jkasun
Created January 21, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkasun/99af0f57ec9bfffc73146b35ea03a2a7 to your computer and use it in GitHub Desktop.
Save jkasun/99af0f57ec9bfffc73146b35ea03a2a7 to your computer and use it in GitHub Desktop.
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