All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
Also, as far as I know local variables(dy, dx) should be initialized at the time of declaration as they do not get default values like that of instance variables.
Also, as far as I know local variables(dy, dx) should be initialized at the time of declaration as they do not get default values like that of instance variables.
That is not correct. local variables have to be initialized before they are used (not necessarily at the time of declaration).
-Paul.
If you like our products and services, please help us by posting your review here.
public class CrazyMath {
public static void main(String[] args) {
int x = 10, y = 20;
int dx, dy;
try{
dx = x % 5;
dy = y/dx;
}catch(ArithmeticException ae){
System.out.println("Caught AE");
dx = 2;
dy = y/dx;
}
x = x/dx;
y = y/dy;
System.out.println(dx+" "+dy);
System.out.println(x+" "+y);
}
}
I am sorry I don't understand what you mean. The error message you posted above indicates that you have special characters in your code. If you copied and pasted the code from ETSViewer, you might get that problem because of space characters.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Oh, now I get it. I did actually copy pasted it from ETSViewer which might have caused the compiler to throw an error corresponding to space characters as you have mentioned. Guess I'll have to rewrite it.