public boolean has22(int[] nums)
{
for (int i=0; i<nums.length-1;i++)
if (nums[i]==2 && nums[i+1]==2)
return true;
return false;
}
You can write your program like above no need of braces.
for each conditional statement one statement is always there if we want to associate more than one statement with any conditional statement then we provide {} braces for example
if(some condition)
stmt1;
no need of braces but if more than one statement then
if(some condition)
{
stmt1;
stmt2;
}
so always remember more than one statement braces compulsory and to avoid problem when ever open a bracket just close at the same time and write inside that one it will let you some relax.
Thanks
asif aftab