Skip to content

Instantly share code, notes, and snippets.

@IacovColisnicenco
Created May 26, 2022 15:53
Show Gist options
  • Save IacovColisnicenco/f3ac74e71ed7f362d4e5852e3ea8896a to your computer and use it in GitHub Desktop.
Save IacovColisnicenco/f3ac74e71ed7f362d4e5852e3ea8896a to your computer and use it in GitHub Desktop.
import java.util. *;
public class MyClass {
public static void main(String args[]) {
class User {
int age;
String name;
public void hasAccess() {
if(age>=18){
System.out.println("Hello "+ name + ", access permited");
}else if(age<18) {
System.out.println("Hello "+ name + ", access denied!");
}
}
}
User anna = new User();
anna.name = "Anna";
anna.age = 17;
User iacov = new User();
iacov.name = "Iacov";
iacov.age = 34;
anna.hasAccess();
iacov.hasAccess();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment