Problem : ArrayIndexOutOfBoundExceptions: 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • makweatan
    New Member
    • Jun 2009
    • 11

    Problem : ArrayIndexOutOfBoundExceptions: 1

    Hi,

    Can anyone please solve this problem?

    I am getting the error message :

    SystemErr R java.lang.Array IndexOutOfBound sException: 1

    the error pointed to the fourth line in this code.
    What should I put in the code?

    Code:
    for(int i=0;i<assmnt_year.length;i++)
    		    {
    		    	{//bayaran dalam tempoh
    		    	if(payment_before_penalty[i]!=null && payment_before_penalty[i].length()==0)
    		    		payment_before_penalty[i]="0";
    		    	else
    		    		payment_before_penalty[i]=Util.removeComma(payment_before_penalty[i]);
    		    	
    		    	//denda 107B3
    		    	if(penalty_107B3[i]!=null && penalty_107B3[i].length()==0)
    		    		penalty_107B3[i]="0";
    		    	else
    		    		penalty_107B3[i]=Util.removeComma(penalty_107B3[i]);
    		    	
    		    	//denda 107B4
    		    	if(penalty_107B4[i]!=null && penalty_107B4[i].length()==0)
    		    		penalty_107B4[i]="0";
    		    	else
    		    		penalty_107B4[i]=Util.removeComma(penalty_107B4[i]);
    		    	
    		    	if(paid_amount[i]!=null && paid_amount[i].length()==0)
    		    		paid_amount[i]="0";
    		    	else
    		    		paid_amount[i]=Util.removeComma(paid_amount[i]);
    		    	
    		    	if(paid_amount1[i]!=null && paid_amount1[i].length()==0)
    		    		paid_amount1[i]="0";
    		    	else
    		    		paid_amount1[i]=Util.removeComma(paid_amount1[i]);
    		    	
    		    	if(taxtype_key.trim().equals("1"))
    		    	{
    		    	if(paid_amount2[i]!=null && paid_amount2[i].length()==0)
    		    		paid_amount2[i]="0";
    		    	else
    		    		paid_amount2[i]=Util.removeComma(paid_amount2[i]);
    		    	}else
    		    	{}
    		    	if(reduce_amt.length==0)
    		    	{}
    		    	else
    		    	{
    		    	if(reduce_amt[i]!=null && reduce_amt[i].length()==0)
    		    		reduce_amt[i]="0";
    		    	else
    		    		reduce_amt[i]=Util.removeComma(reduce_amt[i]);
    		    	}
    		    	//denda 10
    		    	if(penalty_amt1[i]!=null && penalty_amt1[i].length()==0)
    		    		penalty_amt1[i]="0";
    		    	else
    		    		penalty_amt1[i]=Util.removeComma(penalty_amt1[i]);
    		    	
    		    	//denda 5
    		    		if(taxtype_key.trim().equals("1"))
    		    	{
    		    		if(penalty_amt2[i]!=null && penalty_amt2[i].length()==0)
    			    		penalty_amt2[i]="0";
    			    	else
    			    		penalty_amt2[i]=Util.removeComma(penalty_amt2[i]);
    		    	}
    		    	else{}

    Thank u very much.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    It means the array element referenced does not exist
    Code:
    payment_before_penalty[i]
    It is the population of the array where the problem originates.
    If you don't know how many elements there are then maybe for() is the wrong loop

    Comment

    Working...