this is my code can i print my array without zero if it is empty?
import java.util.Arrays;
import java.io.*;
public class Stacks{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("what is the size of your stack? :");
int size = Integer.parseInt (br.readLine());
int get = size;
int[] Array = new int[size];
System.out.println("type: push , pop , exit");
System.out.println("remember! you can EXIT anytime");
System.out.println(Arrays.toString(Array));
/*there still a code here but this is just what i needed to show..*/
}
}
please help me.. PS I don't want to import stacks..
[]not0.intwill have some value.[]. If you have an array of size 5 then it contains 5 ints, which are initialized to 0. It appears intend to treat the array as a stack in the rest of your code, but then what happens if users put0on your stack. Do those0s need to be printed or not?