2

The new Java shell, jshell, allows tab completion which shows all methods available to a given instance of a class. For example, If I do...

jshell> Integer myInt = 3
myInt ==> 3

jshell> myInt. <<< + TAB >>>
byteValue()     compareTo(      doubleValue()   equals(         floatValue()   
getClass()      hashCode()      intValue()      longValue()     notify()       
notifyAll()     shortValue()    toString()      wait(

...I see all of the methods available to an Integer object. How do I see the methods and variables available to the class at large, not just an instance of the class?

awwsmm
  • 1,353
  • 1
  • 18
  • 28
  • 2
    But the list of all inherited methods is displayed on a single tab hit (I see methods inherited from Object and Number). Or is what you're looking for that it show declared methods on single tab and inherited methods on a double tab? – ernest_k Jan 15 '18 at 17:15
  • Not for me. The ones listed above look to be the "Instance Methods" [ https://docs.oracle.com/javase/9/docs/api/?java/lang/Integer.html ] only. What methods do you see, Ernest? Also, whoever downvoted, please explain what's wrong with the question. – awwsmm Jan 15 '18 at 20:16

1 Answers1

2

An instance of Integer will only show the instance variables and methods [ 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(

...while non-instance methods and variables can be seen by simply refraining from creating an instance:

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(
awwsmm
  • 1,353
  • 1
  • 18
  • 28