Advertisement Remove all ads

Define a class to accept and store 10 strings into the array and print the strings with an even number of characters. - Computer Applications

Advertisement Remove all ads
Advertisement Remove all ads
Short Note

Define a class to accept and store 10 strings into the array and print the strings with an even number of characters.

Advertisement Remove all ads

Solution

import java.util.*;
public class Strings
{
       public static void main(String[] args)
       {
             Scanner sc=new Scanner(System.in);
             String[] strArray = new String[10];
             System.out.println("Enter 10 Strings:");
             for (int i=0;i<3;i++)

                strArray[i]=sc.nextLine();
            for (int i=0;i<3;i++)
            {

               if (strArray[i].length() %2=0)
               System.out.println(strArray[i]);
            }
       }
}
Concept: String Array
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×