Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need some help with my first assignment

 
Shon Shalit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, i'm a complete java newbie, i took a C++ class a year ago, and i did pretty well, so i know my way around loops. i already made a for loop that will run 100 times, the only problem now is i don't know the code that would allow the user to input something for the app to print.(i think in C++ it was called cin)

thanks in advance
 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the String parameter from your main() and see if that works.
Or maybe use BufferedReader?
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the command prompt if you are in your development directory just type:
java nameofapp argument

The string you have provided as the argument is passed into main and if your code runs as anticipated, all should be well
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get command-line parameters using the "args" array (sort of like in C++). To get user input while the program is running you can use the Console class (call System.console()).
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shon --
There are links on the page with the assignment with tutorials. The one you're going to need is: http://www.javaranch.com/drive/command.html

Most assignments have some hints included in them or as links. Keep your eye out!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic