1
2, 1
1, 2, 3
4, 3, 2, 1
...............
.................
....................
...................... (upto 10)
notice the absence of comma at the end of the last integer
Can someone please help me.
Thanks in advance
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
1
2, 1
1, 2, 3
4, 3, 2, 1
...............
.................
....................
...................... (upto 10)
notice the absence of comma at the end of the last integer
Can someone please help me.
Thanks in advance
Well, here's the deal: Assuming this is the desired output of a program, every number will be printed because an instruction in the program prints it.
Furthermore...
Every comma will be printed because an instruction in the program prints it.
So...
If you don't want a commas at the end of the last integer on the lines, then don't put instructions in the program to print them.
If we could see your code, maybe we could understand why it prints stuff that you don't want (assuming that's the kind of help you would like).
Cheers!
Z
Last edited by Zaphod_b; September 4th, 2012 at 10:25 PM.
In a loop, just create a check if it's 1 don't follow it with comma, else keep printing the number following comma.
Remember, if it's 1, if it's other than 1, i hope you can make the logic.
Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.
- Henry Ford
Ops yeah it's first ascending then descending. Yeah you are right jps.
Yeah then that would become for getting the size if let's assume (i is dealing in the loop) i has the value which is almost gonna end up the loop after the iteration, don't put comma otherwise continue with the other statements.
Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.
- Henry Ford