Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The Local Variable May Not Have Been Initialized

843810Mar 13 2006 — edited Apr 5 2006
Hi all;

There is a problem that i didnt understand..?Java assigns the initial value of defined variables.isnt it?I have a merge sort algorithm below but for C array the error is:
The local variable C may not have been initialized

in one of if and else statement C[ ] have to get a value...So i didnt understand whats the problem...Please dont say only,give an initial value to C[ ] :)

code is below; thanks for any suggestions
	public static void MergeSirala(int[] A,int[] B) {
		int i=1,j=1;
		int n,m;
		int[] C;
		
		n=A.length;
		m=B.length;
			
		A[n]=B[m-1];
		B[m]=A[n-1];
		
		for(int k=0;k<n+m;k++)
		{
			if(A>B[j])
{
C[k]=A[i];
i++;
}
else
{
C[k]=B[j];
j++;
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2006
Added on Mar 13 2006
9 comments
1,011 views