i'm asking from the user to add the length of the array signal and after that if the size of signal is greater than 2 i create a new array smooth which the first value of it is

smooth[0]= (signal[0]+signal[1])/2;

the second till the last-1 is

for (int i=1; i < (smooth.length-1); i++)
    	   {
    		smooth[i] = (signal[i-1]+signal[i]+signal[i+1])/3;
    	      		      	
           }

and for the last element of smooth average the last two elements of signal
so i wrote

smooth[smooth.length]= (signal[signal.length]+signal[signal.length-1])/2;

i compile it and it's just fine but when i execute and after i enter the numbers

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at Homework7.main(Homework7.java:35)
line 35 is the code

smooth[smooth.length]= (signal[signal.length]+signal[signal.length-1])/2;

i manage to fix it:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.