Leave a Reply 2

Your email address will not be published. Required fields are marked *


renko

renko

Code Question:

public class Alpha {
public String[] main = new String[2];
Alpha (String[] main) {
for (int ii = 0, ii < main.length; ii++) {
this.main[ii] = main[ii] + 5;
}
}
public void main() {
System.out.print(main[0] + main[1]);
}

}

public class Test {

public static void main(String[] args) {
Alpha main = new Alpha(args);
main.main();
}

}

And the commands:
javac Test.java
java Test 1 2

Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – variable ii is already defined in constructor Alpha(java.lang.String[])
at Alpha.(Alpha.java:4)
at Test.main(Test.java:4)

coder

coder

i got 1525 as output