• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing a string

 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
helo everyone I am back with a question again , hope to get some clue how to slove it .

I want to print:


N
NI
NIT
NITI
NITIN
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easy, with a couple of for loops.
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
Easy, with a couple of for loops.


please could you give me some more hint .
I want some more please .
 
Henry Wong
author
Marshal
Pie
Posts: 21446
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please could you give me some more hint .
I want some more please .


It would help if you explain to us how you interpreted the previous hint. How do we know what the next hint is, if we don't know what you did? For all we know, you didn't understand what "couple of for loops" meant, ignored it, and is back to square one.

Henry
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we have to take two loops

 
Rob Spoor
Sheriff
Pie
Posts: 20613
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close. You'll want to change that println into print, and add a println without any parameters after the inner for loop. Otherwise you will be printing one letter on each line.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to check about the []. You have [var] before something, which isn't permissible Java. You also have [var+[i] which won't work because the [] aren't correctly paired off. You will need to go through the String class and find its methods (there are lots of methods, but two you might actually want) which will help you get something useful to print out.

And if you have a for loop, try to avoid putting a number in the middle part. You should be able to get a length parameter or a length method from things and that can be used instead of the 5 you are using.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And count very very carefully how many times your outer for loop will run.
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks every one and specially Campbell Ritchie ,you are very encouraging and supportive
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nitin ratra:
thanks every one . . .
You're welcome.

Please show us what you have got, and how well it works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic