While learning java through an online course, I came across type conversions using helper classes. Eg:
double d = 5.99;
double do = new Double(d);
int i = do.intvalue();
However they doesn't explain how can I find the methods like do.intvalue()
if I am unaware of the existing methods. In Python, I can do a dir(do)
and it would list all the methods. How can I check the same in Java?
You can use javap for the same.
javap java.lang.Double | grep -i int
public static final int MAX_EXPONENT;
public static final int MIN_EXPONENT;
public static final int SIZE;
public int intValue();
public int hashCode();
public int compareTo(java.lang.Double);
public static int compare(double, double);
public int compareTo(java.lang.Object);
For eg. If you see System.out.println()
, but wondering what else could be available, you can always check
javap -c java.lang.System | grep -i out
public static final java.io.PrintStream out;
public static void setOut(java.io.PrintStream);
4: invokestatic #4 // Method setOut0:(Ljava/io/PrintStream;)V
8: putstatic #98 // Field out:Ljava/io/PrintStream;
and then do javap java.io.PrintStream
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With