Q:

Write a Java program to create a new string of 4 copies of the last 3 characters of the original string

0

Write a Java program to create a new string of 4 copies of the last 3 characters of the original string. The length of the original string must be 3 and above


Sample Output:

3.03.03.03.0

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.lang.*;
 public class Exercise68 {
 public static void main(String[] args)
 {
   String main_string = "Python 3.0";
      
   String last_three_chars = main_string.substring(main_string.length() - 3);
   System.out.println(last_three_chars + last_three_chars + last_three_chars + last_three_chars);
  }
    }

Sample Output:

3.03.03.03.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now