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.

Results 1 to 4 of 4

Thread: How to print each letter of string in reverse order in separate line?

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to print each letter of string in reverse order in separate line?

    I'm having real trouble understanding this so apologies as I'm sure it's very basic! I think I've fixed the first couple of lines but struggling to understand how all these statements work. Can anyone see what this is supposed to be and how it should be written?

    public class Test { 
        public void main(String[] args){ 
           int i; for (i =0; i<10; i++){ 
               sum=sum+i; 
        if (i<j); 
        System.out.println(i); 
        else  
         System.out.println(j); 
        while(i<10); 
        { 
        j++; 
    };
    do{
        j++;
    }while(j<10) 
    }
    Last edited by Deep_4; November 7th, 2012 at 12:40 PM.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Wrong code, complete newbie sorry!!

    um... what is your program supposed to do? Without knowing that, it's very difficult to know how it is wrong.

    Also, please edit your post and put [code=java] [/code] tags around your code so that it might be readable.

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Wrong code, complete newbie sorry!!

    Have put the code round it, thanks didn't know that
    That's the problem though is that the challenge is to find out what is wrong and what it is supposed to do...
    The original code was:

    Public classTest { 
        Public void main(String[] args){ 
           for (int i =0;i<10;i++); 
               sum+=i; 
        if (i<j); 
        System.out.println(i); 
        else  
         System.out.println(j); 
        while(i<10); 
        { 
        j++; 
    };
    do{
        j++;
    }while(j<10) 
    }

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Wrong code, complete newbie sorry!!

    Quote Originally Posted by Razzle View Post
    I'm having real trouble understanding this ...
    The so-called code is crap. (Sorry if that sounds harsh, but it is really, really, crap. Crap on a stick, wrapped in crap.) Besides the missing variables and syntax errors, the sequence is, simply, nonsense.

    You are telling us that you don't know what it is supposed to do? Where did you get the code? Found it under a cabbage leaf? The stork brought it? (That's a rhetorical question. I don't want an answer.)

    Does that sound too harsh? Well, since you are asking us what it is supposed to do, I am assuming that you didn't write it, so you shouldn't be offended. At least that's the way I see it.

    I can't imagine that looking at two dozen lines of nonsense can lead to understanding of the language or its applications. Can't you find some real code from a tutorial or a textbook or class notes (or something) to study?

    My recommendation: Get some "real" code. Compile it. Execute it. Study it. Make modifications and see if you can make sense out of the results.

    After studying whatever source material was available wherever you got the code, if there are parts that you don't understand, please post again and ask specific questions. There are lots of folks here who like to help (really) but we gotta have something to work with. Not c*** (Oh, great! Now the swear filter kicks in.)


    Cheers!

    Z
    Last edited by Zaphod_b; October 31st, 2012 at 05:49 PM.

  5. The Following User Says Thank You to Zaphod_b For This Useful Post:

    curmudgeon (October 31st, 2012)

Similar Threads

  1. [SOLVED] I dont know how to complete this code?
    By jwb4291 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 8th, 2017, 11:11 PM
  2. How to import code in NetBeans and make it complete.
    By Chemical91 in forum Java IDEs
    Replies: 3
    Last Post: June 28th, 2012, 07:07 AM
  3. whats wrong? help to newbie
    By ribhoo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 28th, 2011, 04:23 PM
  4. Complete newbie keybinding
    By Peperono in forum AWT / Java Swing
    Replies: 4
    Last Post: November 11th, 2011, 06:05 PM
  5. How to complete code
    By Shay in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 5th, 2010, 01:59 PM