-There is series like - 7,7,7,8,7,7,8,8,8,7,7,7,7,7,8,8,8,8,7
-Find out occurence of 7 Output- 4
-Find out occurence of 8 Output- 3
-Maximum Occurence of 7 in one time- 5
Maximum Occurence of 8 in one time- 4

We won't do it for you. If you have a solution, but it is not working, show us, and we'll try to correct you. If you want some conceptual help, then ask us what you're confused about.

not to mention 7 occurs a lot more times than 4.

``````int[] array={7,7,8,8,7,7,7,8,8,8};
int length=array.length;
System.out.println("length"+length);
for(int i = 0; i < length; i++)
{
for(int j = i+1; j < length; j++)
{
if(array[i] == array[j])
{
array[j]=array[j+1];
length=length-1;
}
else if(array[i] == array[j-1])
{
array[j]=array[j-1];
length=length-1;
}
}
}
System.out.println("length"+length);
System.out.println("after removing repeated element");
for(int i = 0; i < length; i++)
System.out.println(array[i]);
``````

Output Should be - 7,8,7,8
but i am getting 7,8,8

First, you don't need 2 loops. Create an int i=0, out of the loop and then increment it inside while looping. in your case you don't want to have more than 2 7s and more than 2 8s. Create variables to take care of that(which could happen in the "if"statements such as numbers7<2. Idea for the if statements is
if(number[i]==number[j] && numbers7<2&&number[i] ==7) ,likewise for else if and for else just increment i (That's a case where you have i=7 and j=8).Start from here if you face troubles come back ;)

Actually i want that there are numbers which are consecutively repeated i want to remove consecutive repeatation like
no are - 7,7,7,8,8,7,7,8,8,8,7,7,7,8,8,8
output-7,8,7,8,7,8.
i have a problem that how to store new array

don't use an array for the result, use a list.
if you use an array, that implies you know before you run your code the number of elements, which you don't.

``````list result;

while(iteration){
if ( currentElement isFirstElement OR currentElement != previousElement ){