Illegal start of expression
Hello I just started a new java course at uni without having any java experience before.
i am trying to write a quicksort code but i get the message:
Illegal start of expression
when i try to compile a part of my code.
The compiler highlights the underlined code:
public class Quicksort
{
public static void main(String[] args)
{
/*this code will give an array with all numbers larger or equal to the pivot
at its right and all numbers smaller at its left*/
int [] v; int l = v.length; int i=0; int j= l-1; p=v[0]; int k=0;
//[6,3,8,7,9,4,5,2,1]
void quickSortInner ([]v, i, j)
{
for (i<=l; i++)
{
if v[i+1]<p
{int a = v[i+1];
v[i+1] = p;
v = a;
k++;
}
[...]
Message was edited by:
Iced_jacob
Message was edited by:
Iced_jacob>
The compiler highlights the underlined code:
public class Quicksort
{
public static void main(String[] args)
{
/*this code will give an array with all numbers larger or equal to the pivot
at its right and all numbers smaller at its left*/
int [] v; int l = v.length; int i=0; int j= l-1; p=v[0]; int k=0;
//[6,3,8,7,9,4,5,2,1]
public void quickSortInner(int []v, int i, int j)=
{
for (i<l; i++)
{
if v[i+1]><p
[...]
>
It looks like your quick sort method is inside the main method. You cannot do this. It should look like this:public class Quicksort {
public static void main(String[] args) {
// ...
}
public void quickSortInner(...) {
}
}
There is also an "=" sign after quickSortInner(int []v, int i, int j) which shouldn't be there.
And try to use new lines! This is just horrible:int [] v; int l = v.length; int i=0; int j= l-1; p=v[0]; int k=0;