Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with these java programming questions What does the array list mylnt

ID: 3814074 • Letter: P

Question

Please help with these java programming questions

What does the array list mylnts contain at the end of this code segment? What does this method do? In one short English science describe the task accomplished by this method. What does this method do? In one short English sentence describe the task accomplished by this method. Write a static method named concatenate that takes two ArrayLists of Strings as a parameter and returns a new ArrayList of Strings that contains all of the elements of the first list followed by all of the elements of the second list.

Explanation / Answer

Solution for the 6th Problem :-

Program :-

import java.util.*;
class StringArray
{
   public void arrayString()
   {
       int size1,size2;
       System.out.println("Enter how many strings you want in first array");
       Scanner in=new Scanner(System.in);
       size1=in.nextInt();
       String[] str1=new String[size1];
       System.out.println("Enter "+size1+" Strings");
      
       for(int i=0;i<size1;i++)
       {
           str1[i]=in.next();
       }
       System.out.println("Enter how many strings you want in second array");
       size2=in.nextInt();
       String[] str2=new String[size2];
       System.out.println("Enter "+size2+" Strings");
       for(int i=0;i<size2;i++)
       {
           str2[i]=in.next();
       }
       String[] finalString=concatenate(str1,str2);
       System.out.println("The all Strings are");
       for(int i=0;i<finalString.length;i++)
       {
           System.out.println(finalString[i]);
       }
      
   }
   public static String[] concatenate(String[] str1,String[] str2)
   {
       int size=str1.length+str2.length;
       String[] str3=new String[size];
       for(int i=0;i<str1.length;i++)
       {
           str3[i]=str1[i];
       }
       for(int i=str1.length,j=0;i<size;i++,j++)
       {
           str3[i]=str2[j];
       }
       return str3;
   }
}
class FinalString
{
   public static void main(String args[])
   {
       StringArray b=new StringArray();
       b.arrayString();
   }
}

Output

Enter how many strings you want in first array
2
Enter 2 Strings
hello
how
Enter how many strings you want in second array
3
Enter 3 Strings
are
you
now
The all Strings are
hello
how
are
you
now