1.Declare and create a String array , named stringArray , of length 100 , such t
ID: 3716443 • Letter: 1
Question
1.Declare and create a String array , named stringArray, of length 100 , such that its elements contain the userids of students. Obtain the userids from the user , one by one, and write into the array.
2.Write the statements required to read and print all the elements of a String array that contains 100 elements. Assume that the array named, stringArray is already declared and filled with values. You just need to output the contents of this array.
Just write the needed statements, you don’t need to create class.
Explanation / Answer
Ans:1
String [] stringArray = new String[100];
Scanner in = new Scanner(System.in);
for(int i = 0; i<100; i++)
{
System.out.println("Enter the User ID of student :"+(i+1)+": ");
stringArray[i] = in.nextLIne();
}
===============================================================
Ans:2
System.out.println("All Element of the stringArray are: ");
for(int i = 0; i<10; i++)
{
System.out.println(stringArray[i]);
}
===============================================================
KIndly Check and Verify Thanks..!!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.