Person { private final String name; private final int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } } case class Person(name: String, age: Int)
{ A getValue(); } class Node<A> implements BinTree<A> { private final A value; private final BinTree<A> lhs, rhs; public Node(A value, BinTree<A> lhs, BinTree<A> rhs) { this.value = value; this.lhs = lhs; this.rhs = rhs; } public A getValue() { return value; } public BinTree<A> getLhs() { return lhs; } public BinTree<A> getRhs() { return rhs; } } class Leaf<A> implements BinTree<A> { private final A value; public Leaf(A value) { this.value = value; } public A getValue() { return value; } } sealed trait BinTree[A] { val value: A; } case class Node[A]( val value: A, lhs: BinTree[A], rhs: BinTree[A]) extends BinTree[A] case class Leaf(val value: A) extend BinTree[A]
def __init(self, value): self.value = value class Node(BinTree): def __init__(self, value, lhs, rhs): super().__init(value) self.lhs = lhs self.rhs = rhs class Leaf(BinTree): def __init__(self, value): super().__init(value) sealed trait BinTree[A] { val value: A; } case class Node[A]( val value: A, lhs: BinTree[A], rhs: BinTree[A]) extends BinTree[A] case class Leaf(val value: A) extend BinTree[A]