StringBuffer problem

Hi ,

I am trying to put the different string arrays into a string buffer. Here is my code

publicclass StringBufferTest{

/**

* @param args

*/

publicstaticvoid main(String[] args){

// TODO Auto-generated method stub

String[] ruleNames ={"testrule","testrule1"};

String[] textBox1 ={"purchaseprice","debit","income","purchaseprice"};

String[] textBox2 ={"income","5000","5000","income"};

String[] textBox3 ={"","and","",""};

StringBuffer sb =new StringBuffer();

for(int i =0;i<ruleNames.length;i++)

{

for(int j =0;j<textBox1.length;j++)

{

if(i ==1)

{

sb.append(ruleNames[i]+"\t"+textBox1[j]+"\t"+textBox2[j]+"\t"+textBox3[j]+"\n");

}

}

}

System.out.print(sb.toString());

}

}

Here is the output i am getting

testrule1purchasepriceincome

testrule1debit5000and

testrule1income5000

testrule1purchasepriceincome

But actually i am lookinf for the following output

testrulepurchasepriceincome

testrule debit5000and

testrule1income5000

testrule1purchasepriceincome

where i am doing the mistake.

regards,

Krishna>

[2603 byte] By [Rampa] at [2007-11-27 0:48:40]
# 1

If i remove the condition

if(i ==1)

{

sb.append(ruleNames[i]+"\t"+textBox1[j]+"\t"+textBox2[j]+"\t"+textBox3[j]+"\n");

}

then also the output is not comming according to my requirment.

regards,

Krishna

Rampa at 2007-7-11 23:17:43 > top of Java-index,Java Essentials,New To Java...
# 2
if(i ==1)toif(j >=(i*2) && j < ((i+1)*2))
rym82a at 2007-7-11 23:17:43 > top of Java-index,Java Essentials,New To Java...
# 3
thanks for your reply rym. it is working fine
Rampa at 2007-7-11 23:17:44 > top of Java-index,Java Essentials,New To Java...