Reputation: 45
For some reason, Command prompt isn't providing me with a local variable table, even though I am using the -l option. Any suggestion/points?
Edit, here is the code for SumSqrt class:
public class SumSqrt {
/** Calculates the sum of the square roots of the elements of an array.
* @param a the array
* @return Sum (i = 0 to a.length-1) Math.sqrt(a[i])
*/
public static double sumSqrt(double[] a) {
double sum = 0.0;
for(int i = 0; i<a.length; i++) {
sum = sum + Math.sqrt(a[i]);
}
return sum;
}
public static void main(String[] args) {
double[] array = {2,10,30,44,9};
System.out.println(sumSqrt(array));
}
}
Upvotes: 1
Views: 412
Reputation: 55
Use the command
javac -g SumSqrt.java
After that use
javap -l SumSqrt.class
To store this output to file
javap -l SumSqrt.class > SumSqrt.txt
Upvotes: 1