Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java programming

 
winny dhar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello..
friends if i want to print numbers 1 to 100 without using loops what logic would be applied in this??
using loops to i can make but without i am not getting ..
 
Srinivas Reddy Mudimala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make use of label,break,continue and if keywords to get the output
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Other than the obvious (100 separate print statements ), assuming this is an exercise it's probably looking for you to use a recursive method (i.e. a method that calls itself).
 
winny dhar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanku.. ya i got it using recursion..
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Make one method with you print statement and call it recursively it till a flag value is 100
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Other than the obvious (100 separate print statements )

amateur...I can do it with one print statement.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic