My code is as below. i need to add single quotes for each word in string with single quotes after appending DD to it.
public class Main
{
public static void main(String[] args) {
String ChkboxIds = "'a1b2c3','321cba','123abc'";
String checkBoxId = null;
String checkId = null;
StringBuilder checkIDS = new StringBuilder("'");
for(int i=0;i<=ChkboxIds.split(ChkboxIds, ',').length;i++){
checkBoxId = "DD"+ChkboxIds.split(",")[i].replace("'","")+","+checkBoxId;
checkId = checkBoxId.substring(0, checkBoxId.length() - 5);
System.out.println("---PRINT---"+checkId);
for(int j=0;j<i;j++){
checkIDS..append('\'').append(checkId.split(",")).append('\'').append(',');
System.out.println("---PRINT123----"+checkIDS);
}
}
}
}
I have tried using StringBuffer too. please point your answers here. The output i get is some junk data while i need the words with dd attached at the start.
Expected output:'DDa1b2c3','DD321cba','DD123abc'

checkIDS..append('\'').append(checkId.split(",")).append('\'').append(',');beforethe first append there is 2 dots, delete one