I am referring to my previous question but this time I used the java compiler and the compiler compiles the output- it gives a weird output. And this time I used this
instead of super
.
This is the code of the program.
class Con {
int x = 10;
Con() {
this(2);
System.out.println("x :" + x);
}
Con(int i) {
x = i;
System.out.println("x :" + x);
}
}
class DemoCon {
public static void main(String args[]) {
Con c1 = new Con();
}
}
What do you think is the problem here? Is this a bug in Java?
Java version - 1.6.0 JDK
I used Eclipse to run the program and there is a Class not found exception.
A.java
is the file name... We did a minor edit and made a public class called A.java
too but the results are same. We further found out that the problem lies in the compiler.
On Windows it seems CON is reserved name and cannot be used for folders/directories or filenames.
The following
print "test" > Con.java
is not working.
Therefor the compiler is unable to create your Con.class and crashes.
From MSDN:
Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended
perhaps the problem exists because CON
is a reserved file name (it was on MS-DOS -- see http://support.microsoft.com/kb/31157 http://www.computerhope.com/copyhlp.htm)
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