String Program in Java

0
Program to Reverse String :-

class StringRev
{
public static void main(String args[])
{
    String s = "welcome in shiva concept solution";
    for(int i=s.length()-1;i>=0;i--)
    {
          System.out.print(s.charAt(i));

    }


}

}


Program to replace each correct or String to Consecutive Char?



class StringRev
{
public static void main(String args[])
{
    String s = "welcome in shiva concept solution ";
    String arr[] = new String[6];
     int j=0;
     String s1="";
     for(int i=0;i<s.length();i++)
     {
        if(s.charAt(i)!=' ')
          s1+=s.charAt(i);
        else
        {
         arr[j]=s1;
         j++;
         s1="";
        }
         
         
     }
     for(int i=0;i<5;i++)
     {
        System.out.println(arr[i]);
        char arr2[] = new char[arr[i].length()];
       
        for(int k=0;k<arr2.length;k++)
         {
        int asc=arr[i].charAt(k);
        arr2[i]=(char)(asc+1);
        System.out.print(arr2[i]);
        }
        System.out.println();
     }
 
    System.out.println(s);



}

}

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)