Wednesday, 28 December 2016

java program to insert an character in an array

public class Answer implements QuestionInterface {
@Override
public String func(String str, int index, char ch)
{
   if(str==null)
   {
      
       return null;
   }
                if(index>str.length()+1)
                {
                    return str;
                }
              
                else
                {
StringBuilder st= new StringBuilder(str);
                st.insert(index-1, ch);
                String e=st.toString();
return e;
                }
}
}

Wednesday, 21 December 2016

INTRODUCTION

Hi viewers ,
            This is Aravinthan.V and I had created the blog today. I will post useful information and programs and articles from now. So visit my blog often and keep updating yourselves. Thanks for your support.

Java program to find duplicate element in an array

public class Answer implements QuestionInterface
 {
@Override
public char  func (String s){
char[] ch=s.toCharArray();
        int i,j;
        char b = 0;
        for(i=0;i<s.length();i++)
        {
            for(j=i+1;j<s.length();j++)
            {
                if(ch[j]==ch[i])
                {
                    b=ch[j];
                    break;
                }
            }
        }
        return b;
}
}