Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes printing a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "printing a string" Watch "printing a string" New topic
Author

printing a string

nitin ratra
Greenhorn

Joined: Aug 11, 2008
Posts: 25
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

Joined: Oct 13, 2005
Posts: 38016
    
  22
Easy, with a couple of for loops.
nitin ratra
Greenhorn

Joined: Aug 11, 2008
Posts: 25
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
Sheriff

Joined: Sep 28, 2004
Posts: 18531
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
nitin ratra
Greenhorn

Joined: Aug 11, 2008
Posts: 25
we have to take two loops

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
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

Joined: Oct 13, 2005
Posts: 38016
    
  22
And count very very carefully how many times your outer for loop will run.
nitin ratra
Greenhorn

Joined: Aug 11, 2008
Posts: 25
thanks every one and specially Campbell Ritchie ,you are very encouraging and supportive
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
Originally posted by nitin ratra:
thanks every one . . .
You're welcome.

Please show us what you have got, and how well it works
 
 
subject: printing a string
 
Similar Threads
Cant use object from another class
WA #1.....word association
Posting to bump up my count...
Text box value is not being completely filled with request attribute
The x900 effect ?