Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would like to store 2 elements in 1 index of an array. For example : private static Baby[] babies; //array created babies = new

I would like to store 2 elements in 1 index of an array.

For example : private static Baby[] babies; //array created

babies = new Baby[4]; //4 indexes

Baby baby1 = new Baby("John",1); Baby baby2 = new Baby("Peter",2); Baby baby3 = new Baby("Peter",3); Baby baby4 = new Baby("Peter",4); babies[0] = baby1; babies[1] = baby2; babies[2] = baby3; babies[3] = baby4;

^ this is the hardcoded way of entering elements into indexes.

I want to get the user input for name and age and to be placed in the array[4]. How do i do that?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Explain the recommendations for a windfall recipient.

Answered: 1 week ago

Question

Explain what is meant by non-tradi- tional household.

Answered: 1 week ago