• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Please help! if you can :)

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am new to java and I was hoping somebody could explain how to do the following or provide me a code snippet - any help would be appresiated

I need a method that can loop and prompt the user to enter 2 numbers as int.

Would I use the scanner class to get the user input? Then I need to add them to an ArrayList which can store the two numbers, loop and output the values.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class java.util.Scanner would indeed be suitable for this. Have a look at the documentation for it and see if there are some methods you can use. Also have a look at the documentation for class ArrayList.

You can find a link to the API documentation in by signature below.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by drew taylor:
Hi, I am new to java and I was hoping somebody could explain how to do the following or provide me a code snippet...


We're here to help, but you need to show some effort (especially on homework-type questions). So try writing your own snippet, tell us where you're stuck, and we'll help you figure it out.
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic