Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does my Netbeans IDE doesn't recognize my generic data type? The error says it cannot find symbol E. #2

Open
safiullahzuri opened this issue Oct 21, 2016 · 0 comments

Comments

@safiullahzuri
Copy link

import java.util.Arrays;

public class Ex1 {
//implementing methods getSize, peek, push, pop, isEmpty and toString
final int CAPACITY = 100;
int size;
private E[] array = (E[]) new Object[CAPACITY];

public Ex1() {

}
public int getSize(){
    return size;
}
public E peek(){
    if(size == 0)
        return null;
    else
        return array[size-1];
}

public void push(E o){
    array[size++] = o;
    if (size == CAPACITY){
        E[] temp = (E[]) new Object[CAPACITY*2];
        System.arraycopy(array, 0, temp, 0, array.length);
        array = temp;
    }

}

public E pop(){
    if(size==0)
        return null;
    else
        return array[--size];

}

public boolean isEmpty(){
    return size==0;
}

public String toString(){
    return "stack: "+Arrays.toString(array);
}

}

LuizGsa21 pushed a commit that referenced this issue Oct 24, 2017
Rename TestInventoryStackQueue to TestInventoryStackQueue.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant