vxh.viet
10/11/2017 - 9:46 AM

Fix raw type warning

Fix unchecked call to xxx as a member of raw type yyy

Source: StackOverFlow

Answer:

You are using a raw type in the method declaration. Change,

static void myPush (Stack myStack, int b)

to

static void myPush (Stack<Integer> myStack, int b)

Alternatively, make the method generic on type T like:

static <T> void myPush(Stack<T> myStack, T b) {
    myStack.push(b);
    System.out.println("inserted element is: " + b);
    System.out.println("this is on the stack: " + myStack);
}