Merge 2 array:
create a merge method.
int a[]=new int[]{1,2,3};
int b[]=new int[]{4,5,6};
int c[]=merge(a,b);
for(int i=0;i
5
Anonimo
24 lug 2017
count the no of each element present in the array:
import java.util.*;
public class Solution{
public static void countNumber(String input)
{
HashMap map=new HashMap();
char ch[]=input.toCharArray();
for(char c:ch)
{
if(map.containsKey(c))
{
map.put(c,map.get(c)+1);
}
else
{
map.put(c,1);
}
}
System.out.println(map);
}
public static void main(String args[])
{
String input="1212345456";
countNumber(input);
}
}