Believe it or not, your 2nd attempt is a considerable improvement on the first. What your problem is, however, is what you are printing. Check what System.out.println() does when there is no argument, and think how you can alter it to get it to print out only a space.
Hint: look here, then look for PrintStream which is what System.out is, then look for its methods.
Dinesh Tahiliani
Ranch Hand
Joined: Aug 06, 2007
Posts: 486
posted
0
Can you help me out please, i am passing the println without any argument only. Please help me out guys
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
4
posted
0
Have a look at what prints the * and think how you could print a space.
sachin verma
Ranch Hand
Joined: Mar 25, 2008
Posts: 177
posted
0
till now I could do this only.
And it took 2 hours because I did all these things 6 years back.
And I am working on it
[ May 01, 2008: Message edited by: sachin verma ] [ May 02, 2008: Message edited by: fred rosenberger ]
sachin, it's nice that you can do it, but at the ranch we try to let ranchers solve their problem by giving them hints, not by pasting working code That's why you can see other ranchers giving only hints toward the solution.
I am facing problem in printing the space, so i need the correct direction to get it print, please help me out.. I have listen this forum helps people who are not masters and couldn't code properly.
So ranchers please please help me out. [ May 02, 2008: Message edited by: Dinesh Tahiliani ]
we ARE trying to help you. We will NOT, however, do the work FOR you.
let's back up. forget about printing a diamond. Do you know how to just print a space? and then how to print several spaces? for example, how would you print: I'm only using the 'x' character so you can see the spaces. you should print an x, then the spaces, then another x
Note: you already know how to print something like this with your '*' characters... [ May 05, 2008: Message edited by: fred rosenberger ]
Dinesh Tahiliani
Ranch Hand
Joined: Aug 06, 2007
Posts: 486
posted
0
I don't know how to print spaces in between, that is why i have posted here so that someone can help me out..
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
I don't know how to print spaces in between
If this:
prints out an asterisk character, how might that statement look if you wanted to print out a space character?
Note that the method println() prints whatever you pass to it, and then it goes to the next line. So if you do this:
System.out.println(" "); System.out.println("*");
you'll see a blank line, and a * at the beginning of the next line. If you don't want to move to the next line automatically, use print() instead of println().