I assume that sec1,sec2
are all the string in the array.
char [] sections = {'A','A','B','A','A','B','B','A','A','B'};
int count = 0;
for(int i = 0; i < sections.length - 1; i++)
{
if(sections[i] == 'A' && sections[i+1] == 'A')//compare with what you want to
{
count++;
}
}
System.out.println(count);
EDIT
try
{
String query = "select * from emp;*;
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String []sections = new String[30];
for(int i = 0; i < 30; i++)
{
sections[i] = rs.getString(i+1);
}
//now add your checking logic here...
}
}
catch(Exception e)
{
e.printStackTrace();
}
1
solved Looping check in Java