java Set up a string array to hold the following names: AYESHA, LAILA,SARA, FATIMAH and KHADIJA. Write a program to print them.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

java

  1. Set up a string array to hold the following names: AYESHA, LAILA,SARA, FATIMAH and KHADIJA. Write a program to print them.
Expert Solution
Explanation

Array : 

Array is nothing but the collection of the items of the similar data type . The data type is the type of data if it is the integer or the decimals or the strings . In the above case as in the question we need the array of the strings as those names are in string format . There are 5 names hence we need the array of size 5 . 

Hence to create the array in java the syntax is as follow : 

 

Here is the approach : 

  1. Create the array of strings using the above syntax  of size 5 . 
  2. Add the names in the array one by one . remember that the array start from the index 0 . hence the first element will be at position 0 and last will be at position 4 . But the size will be always 5 .
  3. Now to print the names to the console . Simply iterate over the array from the index 0 to 4 . Print the data to the console .

Check code for more understanding . everything is mentioned in the comments . Check screenshot of the code and output .

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education