473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Hi, Inorder to get input from user, we will ask user how many number of inputs the us

In order to get input from user, we will ask user how many number of inputs the user is going to enter. But now my requirement is to allow the user to enter any number of inputs. How can I Perform it???
One of the way is using while loop.But the problem with while loop is storing the null value. How to initialise the array?
Dec 5 '15 #1
1 1201
chaarmann
785 Expert 512MB
read all inputs in a while-loop until the user types "end".

Do not use static array, but collection framework.
Then there is no need to initalize the array with a fixed size beforehand.

before loop:
Expand|Select|Wrap|Line Numbers
  1. ArrayList numberList = new ArrayList();
in loop:
Expand|Select|Wrap|Line Numbers
  1. numberList.add(number);
after loop:
Expand|Select|Wrap|Line Numbers
  1. System.out.println("size=" + numberList.size() + ", content=" + numberList);
Dec 7 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: valexena | last post by:
Which clause in a create user statement restricts the number of tables a user can add to a tablespace? -- Posted via http://dbforums.com
4
by: santa19992000 | last post by:
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)?. It displays to enter IP address, if user wants to change, then he enters, otherwise he hits keyboard,...
1
by: elain | last post by:
Hi all, My webform contains a repeater, and every item in the repeater is a user control which contains several textboxes. Each time when the page is loaded, I bind a dataset to this repeater to...
4
by: Sylvan | last post by:
I am new with this personalization stuff. Everything was working fine, however, now I always get the Login failed for user ''. The user is not associated with a trusted SQL Server connection....
2
by: ghadley_00 | last post by:
Hi, I have a form that collects information about up to 5 items. I would like the user to be able to select from a drop down menu how many items for which they want to compare information, and...
1
by: suhdominic | last post by:
#include <iostream> #include <fstream> using namespace std; int main() { cout << fixed << showpoint; float a0,a1,a2,a3,a4,a5,a6,a7,a8; // Nine constant values in the polynomial
2
by: stmfc | last post by:
i want to get some values from the user and process them. e.g) enter three numbers: 1 10.5 50 result is 61.5 is it possible to get these three double values from the user without using...
4
by: eruth | last post by:
There are loads of post on this, but nothing that seems to cover my exact problem ;) I have an ASP.Net 1.1 web application running on my local machine. I want to connect to an SQL 2005 server...
6
by: Hnizdo | last post by:
Hello, I've started learning java this semester in school and my level is still quite low. Now i found a problem with my program: I want the program to recognise whether the imput is a number,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.