Write a Java program to take the last three characters from a given string and add the three characters at both the front and back of the string.

 /*

Write a Java program to take the last three characters from a given string and add the three characters at both the front and back of the string. 

String length must be greater than three and more.

Test data: "Python" will be "honPythonhon"

Sample Output:

honPythonhon

*/

import java.util.*; 

class Sixteen 

{

    public static void main(String arg[])

    {   

        Scanner in = new Scanner(System.in);

        System.out.print("\n Enter String : "); 

        String str = in.next();

        String ch = str.substring(str.length() - 3);

        System.out.println("\n " + ch + str + ch);

    }

}

More Information on our channel Programmer Community

please like , share and subscribe to get notifications of new videos....

To understand this program video will coming soon on our you tube channel



Comments

Popular posts from this blog

Design and Develop a java program to read marks of a student and print the total and average of marks using scanner class.

Write a Java program to convert seconds to hour, minute and seconds.

Write a Java program to print the ascii value of a given character.