The exception that the class throws is what you would need to catch. If for example you try to open a file and the file cannot be opened, instead of crashing the program, it would throw an exception. A try/catch or try/catch/finally would be used to catch that exception and deal with it gracefully. If the exception is not dealt with gracefully, the program will crash anyway, regardless of the exception being thrown or not.
There's definitely more to it than that, but I feel as though that's a decent enough overview to point you in the right direction regarding error handling.
Good luck!
Thank you! I'll read more about it later
okay im trying dissect and use this example code while trying to use my values
however it wont compile
// Demonstrate random Gaussian values.
import java.util.Random;
class RandDemo2 {
public static void main(String args[]) {
Random r = new Random();
double val;
double sum = 0;
int bell[] = new int[10];
for(int i=0; i<100; i++) {
val = r.nextGaussian();
sum += val;
double t = -2;
for(int x=0; x<10; x++, t += 0.5)
if(val < t) {
bell[ x ]++;
break;
}
}
System.out.println("Average of values: " +
(sum/100));
// display bell curve, sideways
for(int i=0; i<10; i++) {
for(int x=bell
; x>0; x-)
System.out.print("*");
System.out.println();
}
}
}
RandDemo2.java:23: error: illegal start of expression
for(int x=bell; x>0; x-)
^
RandDemo2.java:23: error: not a statement
for(int x=bell; x>0; x-)
^
I dont understand x- is doing