Consecutive numbers program using array:
class Consecutive
{
public static void main(String[] args)
{
int a[]={52,10,85,14,32,78,15,11,53,86};
int p=a.length;
System.out.println("====Consecutive Numbers Are:====");
for(int i=0;i<p;i++)
{
for(int j=i+1;j<p;j++)
{
if((a[i]+1)==a[j])
{
System.out.println(a[i]+","+a[j]);
}
else{
if(a[i]==a[j]+1)
{
System.out.println(a[j]+","+a[i]);
}
}
}
}
}
}