java - Printing the array -


i trying print contents of array. example have defined int array of size 10. user entered 8 numbers. last 2 positions in array have value of zero. when printing array ten positions. possible print till user entered.also user decides how many enter cannot hard code position printing array. thanks.

is possible print till user entered.

yes, keep track of how many items user entered. can done separate int counter variable increment user enters item, or if want, can fill array values user never enter, example, integer.min_value, , display results until reach non-sense values. danger here is, happens if user happens pick non-sense value? that's why i'd go first suggestion.

also user decides how many enter cannot hard code position printing array.

yep, said above.

edit: or best of all, patricia shanahan says.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -