1. [20%] The method length() of the String class returns the number of characters in a string. (Note that this is different from the length that we used with arrays). Complete the simple program below that prints all the characters of a test string, using thecharAt() method and the length() method. Compile and run it. public class PlayWithStrings { public static void main (String[] args) { String test = “This is a test.”; /* insert your code here */
1. [20%] The method length() of the String class returns the number of
characters in a string. (Note that this is different from the length that we used with arrays). Complete the simple program below that prints all the characters of a test string, using thecharAt() method and the length() method. Compile and run it.
public class PlayWithStrings
{
public static void main (String[] args)
{
String test = “This is a test.”;
/* insert your code here */