class Stack<T> {
List<T> _stack = [];
void push(T item) => _stack.add(item);
T pop() => _stack.removeLast();
}
// Example
final stack = Stack<String>();
stack.push("A string.");
class Person {
String name;
int age;
List<String> likes = ["Coding", "Dart", "Comp Sci"];
String _password = "Password123"; // This is a private variable, using an '_' at the start of a variable name makes it private.
Person(String name, int age, List<String> likes) { // Constructor
this.name = name;
this.age = age;
this.likes = likes;
}
void SetPassword(String password) { // Setter
this._password = password;
}
String GetPassword() { // Getter
return _password;
}
}