<code>Scanner sc = new Scanner(System.in);
System.out.println("Enter the Size of Stack: ");
int size = 0;
size = sc.nextInt();
Stack stack = new Stack (size); /* line code error here */
</code>
<code>Scanner sc = new Scanner(System.in);
System.out.println("Enter the Size of Stack: ");
int size = 0;
size = sc.nextInt();
Stack stack = new Stack (size); /* line code error here */
</code>
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Size of Stack: ");
int size = 0;
size = sc.nextInt();
Stack stack = new Stack (size); /* line code error here */
I tried to insert the int datatype “size” into the stack constructor and it shows this type of error:
“constructor Stack in class java.util.Stack cannot be applied to given types;”
I tried to initialize the size value to 0 to let the stack identify it as a empty stack, but it is still not working.
New contributor
chuckzxxmello is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.