Looping check in Java -
can guide me on how looping compare data using java?
example: have lot of section 1 30
each time need take 2 section compare data (a, a) or not?
i need compare sec1, sec2 if data (a,a)
add 1
output continue compare next section sec2, sec3 , on
...
sec1 sec2 b sec3 c sec4 sec5 e sec6 sec7 . . . . . .
i assume sec1,sec2
string in array.
char [] sections = {'a','a','b','a','a','b','b','a','a','b'}; int count = 0; for(int = 0; < sections.length - 1; i++) { if(sections[i] == 'a' && sections[i+1] == 'a')//compare want { count++; } } system.out.println(count);
edit
try { string query = "select * emp;*; resultset rs = stmt.executequery(query); while(rs.next()) { string []sections = new string[30]; for(int = 0; < 30; i++) { sections[i] = rs.getstring(i+1); } //now add checking logic here... } } catch(exception e) { e.printstacktrace(); }
Comments
Post a Comment