我似乎无法从 JRuby 中调用任何 Java 的字符串方法。不过,同样的语法风格也适用于 Math 类。我究竟做错了什么?
#! /usr/bin/env jruby
require 'rubygems'
require 'java'
puts java.lang.Math::max(1000,200)
puts java.lang.Math::PI
# this doesn't work
puts java.lang.String::toUpperCase("we, the people")
# this doesn't work either
JString = java.lang.String
puts JString.toUpperCase('We, the people')
#toUpperCase exists though, see below
puts java.lang.String.java_class.declarSed_instance_methods