methods1.scm 928 B

123456789101112131415161718192021222324
  1. (display (java.lang.Integer:toHexString 266)) (newline)
  2. ;; Output: 10a
  3. (define (to-hex (x :: <int>)) (java.lang.Integer:toHexString x))
  4. (display (to-hex 267)) (newline)
  5. ;; Output: 10b
  6. (define-namespace Long "class:java.lang.Long")
  7. (display (Long:toHexString 269)) (newline)
  8. ;; Output: 10d
  9. (define (long-to-hex (x :: <long>)) (Long:toHexString x))
  10. (display (long-to-hex 270)) (newline)
  11. ;; Output: 10e
  12. (display (Long:toString (Long:new '00123))) (newline)
  13. ;; Output: 123
  14. (define (to-int-string x :: <long>) (java.lang.Object:toString (Long:new x)))
  15. ;; Diagnostic: methods1.scm:14:37: warning - no static method 'toString' in java.lang.Object
  16. (display (to-int-string '00124)) (newline)
  17. ;; Output: 124
  18. (define-namespace date "class:java.util.Date")
  19. (! year (+ 1900 (date:get-year (date:new))))
  20. ;; Diagnostic: methods1.scm:20:17: warning - no static method 'get-year' in java.util.Date
  21. (write (> year 2015)) (newline)
  22. ;; Output: #t