cancel
Showing results for 
Search instead for 
Did you mean: 

where is error in code

Former Member
0 Kudos

Hi Experts,

I am getting error in my code.Could you please correct me where it is?

public void ElemDetail(String[] Input,ResultList result,Container container){

//write your code here

int Tlength = Input.length();

int position = 0;

int nposition = 0;

int recleng = 0;

int spa = 0;

for(int i=1; i<Tlength; i++)

if (Input.charAt(i) == '+')

{

position = i;

spa = i + 5;

if (Input.charAt(spa) ==' ')

{

for (int j = position1; j<Tlength; j+)

if (Input.charAt(j) =='+' )

{

nposition = j;

recleng = j - 1;

j = Tlength + 1;

result.addValue(Input.substring(position, nposition));

}

}

}

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

There are many errors in code.

for instance: There is no method called Input.charAt() in string array, you can use this method in String and not for String array. it should be Input<i>.charAt() method

you cannot use length() method for string array, you just need to give Input.length .

Go through your code again.

amit

Former Member
0 Kudos

Hi Amit,

Could you please correct the code if possible.

Thanks,

Former Member
0 Kudos

Hi,

The main error of the above code was with Input field. Its Array of String, so the operations that you have added are on string ...thus the Input[k] is required to specify the particular string.

if you will be sending only one value as source side then you should have use the Cache parameter = Value then your previous code will work fine. But for multiple values below is the corrected code.



//write your code here


int position = 0;
int nposition = 0;
int recleng = 0;
int spa = 0;
int Tlength = 0;

for(int k = 0; Input.length>k; k++)
{
	Tlength = Input[k].length();

	for(int i=1; i<Tlength; i++)
	{
		if (Input[k].charAt(i) == '+')
		{
			position = i;
			spa = i + 5;
			if (Input[k].charAt(spa) ==' ')
			{
				for (int j = position+1; j<Tlength; j++)
					if (Input[k].charAt(j) =='+' )
					{
						nposition = j;
						recleng = j - 1;
						j = Tlength + 1;
						result.addValue(Input[k].substring(position, nposition));
					}
			}
		}
	}
}

Thanks

swarup

Former Member
0 Kudos

Thanking you Swarup for your help...

Answers (0)