Static referencing error
Posted
by
maxflow
on Stack Overflow
See other posts from Stack Overflow
or by maxflow
Published on 2012-11-01T04:38:24Z
Indexed on
2012/11/01
5:00 UTC
Read the original article
Hit count: 110
java
public class HelloWorld {
public static void main(String [] args) {
char[] b = {'a', 'b', 'a', 'c'};
int p = 4;
deleteRepeats(b, p);
}
public void deleteRepeats(char[] a, int size) {
int currentElement;
currentElement = 0;
do {
for (int i = currentElement; i < size-1; i++) {
if (a[currentElement] == a[i+1]) a[i+1] = ' ';
}
currentElement++;
} while (currentElement < size-1);
}
}
I get the error:
non-static method deleteRepeats(char[],int) cannot be referenced from a static context deleteRepeats(b,p);
Can someone tell me what this means?
I tried removing "static" from the main method, but I get the error:
Exception in thread "main" java.lang.NoSuchMethodError: main.
Thanks in advance
© Stack Overflow or respective owner