Hi my requirement is to produce following string:
qid<> 0 And qid<> 1 And qid<> 2 And qid<> 3 And qid<> 4 And qid<> 5 And qid<> 6 And qid<> 7 And qid<> 8 And qid<> 9 So I did like this:
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here String deleteQids="qid<> "; String deleteqidString1=""; for(int i=0;i<10;i++) { deleteqidString1+=deleteQids+i +" And "; } System.out.println(deleteqidString1); } } But at the end And appears.
Can anybody please tell me how to get rid of this?
StringBuilderstring.Joinmethod that you can add" and "inbetween each element of a list and this answer gives ideas for doing the same in java: stackoverflow.com/questions/187676/…