---
// ch04_ex17.javaclass ch04_ex17 {
static String string1 = "init at def";
static String string2;
static {
string2 = "init in static block";
}static void demo_inits() {
System.out.println( "string1: " + string1 );
System.out.println( "string2: " + string2 );
}public static void main(String[] args) {
demo_inits();
}
}
---
20:41 -- Starting 4.17, Lisp version
20:52 -- Done
---CLOS doesn't have a "static block" area for initializations, so I punted on this one.
;;;; chapter 4, ex 17
(defclass ch04-ex17 ()
((string1 :initform "init at def"
:allocation :class)
(string2 :initform "init at def, too"
:allocation :class)))
(let ((obj (make-instance 'ch04-ex17)))
(format t "string1: ~a~%string2: ~a~%"
(slot-value obj 'string1)
(slot-value obj 'string2)))
---