Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help! if you can :)

 
drew taylor
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15438
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic