I'm sorry... you can't simply pass nbrs
in the method (here, appropriately, constructor) signature. You need to declare what data type it is...
public class SortMethod {
int[] nbrs;
// ... the other fields.
// This is a 'Constructor'
public SortMethod (int[] nbrs) {
this.nbrs = nbrs;
}
Next, in your invocation of sort()
, you should use something like:
// ...
SortMethod sMethod = new SortMethod(nbrs);
sMethod.sort();
// ...
More appropriately, you could create a static
method that sorts the array, which implies no need for object creation for a trivial task:
public static void sort (int[] nbrs) {
// ... code here.
}
and you can call it as:
// ...
<class_Name>.sort(nbrs); // from any where within the same package without an import.
// ...
TIP: You can try using the library method for your implementation:
// ...
java.util.Arrays.sort (nbrs);
// ...