新的Java shell jshell允许选项卡完成,它显示给定的类实例可用的所有方法。例如,如果我这样做......
jshell> Integer myInt = 3
myInt ==> 3
jshell> myInt. <<< + TAB >>>
byteValue() compareTo( doubleValue() equals( floatValue()
getClass() hashCode() intValue() longValue() notify()
notifyAll() shortValue() toString() wait(
...我看到Integer
对象可用的所有方法。如何查看整个类可用的方法和变量,而不仅仅是类的实例?
答案 0 :(得分:2)
Integer
的实例只会显示实例变量和方法[Oracle]:
jshell> Integer j = new Integer(3)
j ==> 3
jshell> j.
byteValue() compareTo( doubleValue() equals( floatValue()
getClass() hashCode() intValue() longValue() notify()
notifyAll() shortValue() toString() wait(
...虽然可以通过简单地避免创建实例来看到非实例方法和变量:
jshell> Integer.
BYTES MAX_VALUE MIN_VALUE SIZE
TYPE bitCount( class compare(
compareUnsigned( decode( divideUnsigned( getInteger(
hashCode( highestOneBit( lowestOneBit( max(
min( numberOfLeadingZeros( numberOfTrailingZeros( parseInt(
parseUnsignedInt( remainderUnsigned( reverse( reverseBytes(
rotateLeft( rotateRight( signum( sum(
toBinaryString( toHexString( toOctalString( toString(
toUnsignedLong( toUnsignedString( valueOf(