
Consulta con un problema
Publicado por Miguel (1 intervención) el 14/06/2014 06:23:48
Necesito por favor consejos para solucionar este error que me aparece en lasl ineas abajo indicadas,
ERROR: non-static variable this cannot be referenced from a static contest
ERROR: non-static variable this cannot be referenced from a static contest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
public class Quicksort{public static void main(String[] args){
int ne=Integer.parseInt(JOptionPane.showInputDialog("digite en numero de elementos"));
int a[] = new int[ne];
Random rnd = new Random();
for(int d=0;d<a.length;d++)
{int v = rnd.nextInt(10);
a[d]=v;
}long tiempo1= System.currentTimeMillis();
_Quicksort(a,0,a.length-1);
long tiempo2= System.currentTimeMillis();
long tiempototal= tiempo2-tiempo1;
System.out.println("el tiempo total es: " +tiempototal);
//for (int n = 0; n < a.length;n++){
// System.out.println(a[n]);
//}
}public static void _Quicksort(int matrix[], int a, int b)
{this.matrix[]= new int[matrix.length]; //ERROR non-static variable this cannot be referenced from a static contest
int buf;
int from = a; int to = b;int pivot = matrix[(from+to)/2];
do
{while(matrix[from] < pivot)
{from++;
}while(matrix[to] > pivot)
{to--;
}if(from <= to)
{buf = matrix[from];
matrix[from] = matrix[to];
matrix[to] = buf;
from++; to--;
} }while(from <= to);
if(a < to)
{_Quicksort(matrix, a, to);
}if(from < b)
{_Quicksort(matrix, from, b);
}this.matrix = matrix; //ERROR non-static variable this cannot be referenced from a static contest
}}Valora esta pregunta


0