2、
/**
* 找到最长连续数组
* @param a
*/
public static void longestLianXuArray(int a[])
{
String s = "";
int maxLen = 1;
int i = 0; // 其实元素的下标
while(i < a.length)
{
int j = i;
StringBuilder sb = new StringBuilder();
while(j < a.length && j + 1 < a.length)
{
if(a[j + 1] == a[j] + 1)
{
sb.append(a[j]);
j++;
}
else
{
sb.append(a[j]);
break;
}
}
if(sb.toString().length() > s.length())
{
s = sb.toString();
}
i = j + 1;
}
System.out.println(s);
}