Hi team, can some one give me clue for printing this ***** s**** ss*** sss** ssss*
where s is space. using for loop since i am totally mad to achieve this, atlast i posted here [ November 09, 2006: Message edited by: saravanakumar rajendran ]
Originally posted by saravanakumar rajendran: that api is technically advance, i need it for beginners level. any way thanks a lot for your kind reply
Fair enough.. although I would suggest you to learn the API, or atleast know how to look in it and search for usefull methods and information about the different classes.
A more simple solution could be to operate with two strings. This solution is based on the advice you got from Rowe.
Hi to all. I am new to JavaRanch. I am planning to take the SCJP exam (CX-310-055) by the end of Decemeber. I usually come here to see other people's problems, questions, etc. & try to solve them on my own. This helps me check my concepts in various fields. I read the first post and made out the solution in just 2 minutes Here is the code for my Diamond.java in (...)\language\looping\ directory:- (Sorry! The code is un-commented.)
I preferred to declare i, j and k outside the loops, so that variables don't have to be re-created during each iteration.
for (int k=1;k<=5;k++) {for(int z=6-k;z<5;z++) { System.out.print(" "); } for (int l=k+1;l<=5 ;l++ ) { System.out.print("*"); } System.out.println(); } thanks for your kind reply, and this is my answer
Originally posted by Abdul Rehman: [QB]Hi to all. I am new to JavaRanch. I am planning to take the SCJP exam (CX-310-055) by the end of Decemeber. I usually come here to see other people's problems, questions, etc. & try to solve them on my own. This helps me check my concepts in various fields. I read the first post and made out the solution in just 2 minutes Here is the code ....
Hi Abdul,
welcome to the Ranch!
Good job on solving the OPs (Original Posters) problem in 2 mins
General remark:
Please remember that this is the beginners forum and it's therefore important that the OP'ers work out their solution (the techinical one, that is) by themselves. Hints, ideas and pseudo code is to be prefeered over java code in other words.
Now.. the OP seems to have solved the problem already, so posting code here is okay... nevertheless I find it important to stress the importance of the above
If i was recreated during each interation, how would the ending condition ever be reached?
In the problem under discussion, we have nested looping. There is no problem with i, rather, j & (possibly) k would be re-created during each iteration of the outer loop. That's what I meant. One can declare i in the for-loop header; there's no problem with i.