My code is:
public class Q2Client {
public static void main(String[] args) {
Q2 newq2 = new Q2(5);
}
}
class Q2 {
int x;
public void Q2 (int y) {
int x = y;
}
}
I get an error about not accepting an integer (required: no arguments) when creating the newq2, but the Q2 clearly takes an integer. When I remove the void in the Q2 class, it does not give me the error and runs fine. What about the void causes the parameter (int y) to be invalid?