Java:Syntax error on token ";", . expected

[Résolu/Fermé]
Signaler
-
 domxaline -
Bonjour,
prg suivant me donne erreur
Syntax error on token ";", . expected
i cannot be resolved or is not a field

at Fusionner.buildRandomSortedIntArray(Fusionner.java:32)
at Fusionner.main(Fusionner.java:13)
pourtant j'ai bien mis point virgule
import java.util.Arrays;
import java.util.Random;
public class Fusionner 
{
   public static Random random=new Random(System.nanoTime());
   private static final int NB_OF_TEST=10;
   public static void main(String[]args)
   {
	 int maxLength=1;
	 for(int test=0;test<NB_OF_TEST;test++,maxLength*=2)
	 {
		 int[]increasing=buildRandomSortedIntArray(true,random.nextInt(maxLength));
		 int[]decreasing=buildRandomSortedIntArray(false,random.nextInt(maxLength));
		 System.out.println("_____________________________________________________");
		 System.out.println("Croissant:"+Arrays.toString(increasing));
		 System.out.println("Décroissant:"+Arrays.toString(decreasing));
		 int[]merged=new int[increasing.length+decreasing.length];
		 merge(increasing,decreasing,merged);
		 System.out.println("Fusion:"+Arrays.toString(merged));
	 } 
   }
   private static int[]buildRandomSortedIntArray(boolean increasing, int length)
   {
	   int[]array=new int[length];
	   for(int i=0;i<array.length;i++)
		   array[i]=random.nextInt(10*length);
	   Arrays.sort(array);
	   if(!increasing)
	   {
		   int max=0;
		   for(int i=0;max=array.length/2;i<max;i++)
		   {
			   int tmp=array[array.length-i-1];
			   array[array.length-i-1]=array[i];
			   array[i]=tmp;
		   }
	   }
	   return array;
   }
   public static void merge(int[]increasing,int[]decreasing,int[]merged)
   {
	   int leftIndex=0;
	   int rightIndex=decreasing.length-1;
	   
	   int mergedIndex=0;
	   while(leftIndex<increasing.length&&rightIndex>=0)
	   {
		   int leftValue=increasing[leftIndex];
		   int rightValue=decreasing[rightIndex];
		   if(leftValue<=rightValue)
		   {
			   merged[mergedIndex++]=leftValue;
			   leftIndex++;
		   }
		   else
		   {
			   merged[mergedIndex++]=rightValue;
			   rightIndex--;
		   }
	   }
	   if(leftIndex<increasing.length)
		   System.arraycopy(increasing, leftIndex, merged, mergedIndex, increasing.length-leftIndex);
	   else
		   while(rightIndex>=0)
			   merged[mergedIndex++]=decreasing[rightIndex--];
   } 
 }

la ligne 13 est :
int[]decreasing=buildRandomSortedIntArray(false,random.nextInt(maxLength));

la ligne 32 est :
for(int i=0;max=array.length/2;i<max;i++)
{

merci d'avance

1 réponse

j'ai résolu le pb en écrivant comme ça:
int max=array.length/2;
for(int i=0;i<max;i++)