Answer to Question #3480 in Java | JSP | JSF for Y mukundareddy

Question #3480
(3) Write a program to store 5 of your friend’s names in an array.
1
Expert's answer
2011-08-07T07:19:21-0400
import java.io.*;

public class Task10
{
public static void main(String[] args) throws IOException
{
& // Preparing the stream
& BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));

& // reading the names of the friends
& String[] friendNames = new String[5];
& System.out.println("Enter the names of 5 your friends");
& for (int i = 0; i < 5; i++)
& {
& System.out.print("Enter the name of friend " + (i + 1) + ": ");
& friendNames[i] = bReader.readLine();
& }

& // All names are stored in array
& System.out.print("\nNow the array 'friendNames' stores 5 of your friend’s names");
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS