This file contains hidden or 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
trait Logged { def log(msg: String) {} } | |
trait Chattery extends Logged { def chatter = log("I chatter. Do you mind?") } | |
trait ConsoleLogger extends Logged { override def log(msg: String) = println(msg) } | |
scala> val ch = new Chattery() with ConsoleLogger | |
ch: Chattery with ConsoleLogger = $anon$1@1ef7fe8e | |
scala> ch.chatter |
This file contains hidden or 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
public class Employee { | |
private Address addr; | |
private int age; | |
// Getters and setters | |
} | |
class Address { | |
private String streetAddr1; | |
private String streetAddr2; |
This file contains hidden or 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
public class Fraction { | |
private final int num; | |
private final int denom; | |
public Fraction(int num, int denom) { | |
this.num = num; | |
this.denom = denom; | |
} | |
public int getNum() { |
NewerOlder