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 9 of 9

Thread: pattern program

  1. #1
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default pattern program

    [







    package javaapplication38;


    public class JavaApplication38 {


    public static void main(String[] args) {
    int i,j;
    for(i=1;i<=5;i++)
    for(j=1;j<=i;j++) {
    {

    System.out.print(i);


    }
    System.out.println();
    }

    }
    }










    ][m getting output as in netbeans




    1
    2
    2
    3
    3
    3
    4
    4
    4
    4
    5
    5
    5
    5
    5
    BUILD SUCCESSFUL (total time: 0 seconds)
    as the correct output should be as 2
    2
    22
    333
    4444
    55555 it shoul be pattern plz help wat to make changes in code










    ]


  2. #2
    Member
    Join Date
    Feb 2014
    Posts
    38
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    You should put the code brackets around your code so people can view your code easier.
    But I fixed your code, I even posted it on your Profile (after your old thread got locked)

    I fixed the code for ya: (I added if (i>=2) so it wouldn't have a space in the beginning. But if you don't mind, you don't need it. If you don't need it, just add a System.out.println; right after "for(i=1; i<=5; i++)". Msg me if you have questions regarding how I fixed your code!

    .....
    Last edited by copeg; February 16th, 2014 at 10:16 AM. Reason: Removed Spoonfeeding

  3. #3
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    frnd as m new to forum i dont know how post code and highlight can u plz help

  4. #4
    Member
    Join Date
    Feb 2014
    Posts
    38
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    Quote Originally Posted by AJAY KAMBLE View Post
    frnd as m new to forum i dont know how post code and highlight can u plz help
    All you gotta do is write [ c o d e ] [ / c o d e] (without spaces) around your code

    Like [ c o d e]your code here[ / c o d e]

  5. #5
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: pattern program

    hkfrenchtoast, I realize you are trying to help but I suggest taking a look at the following thread: http://www.javaprogrammingforums.com...n-feeding.html

    AJAY KAMBLE, refer to this page: BB Code List - Java Programming Forums - The Java Community
    specifically the section for code.

  6. The Following User Says Thank You to KucerakJM For This Useful Post:

    AJAY KAMBLE (February 16th, 2014)

  7. #6
    Member
    Join Date
    Feb 2014
    Posts
    38
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    Terribly sorry, I will never do that again

  8. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: pattern program

    No worries.

  9. #8
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    gregfrnd okay na now i posted in bracket is it okay frnd becoz u closed the thread before first thread

    --- Update ---

    thnx kucerakjm but can u explain me y u taken if(i>=2)

    --- Update ---

    okay i got i kucerakjm for the space u taken i>=2 thnx a lot

  10. #9
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: pattern program

    // code is right you have added two "{" after 2nd loop so the output is not
    // accordding you chenge your code like that
    *** Code removed.
    See: http://www.javaprogrammingforums.com...n-feeding.html
    Last edited by Norm; February 16th, 2014 at 08:44 AM. Reason: spoonfeeding code does not help op learn to program

Similar Threads

  1. [SOLVED] pattern matching
    By shenaz in forum Java Theory & Questions
    Replies: 3
    Last Post: April 8th, 2013, 10:03 AM
  2. pattern matching
    By shenaz in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 16th, 2013, 11:58 PM
  3. letter pattern
    By severus1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 4th, 2011, 01:24 PM
  4. Regular Expression pattern - complex pattern syntax
    By SmartAndy in forum Algorithms & Recursion
    Replies: 3
    Last Post: June 7th, 2011, 04:40 AM
  5. How to Use an Observer Pattern
    By copeg in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: February 9th, 2011, 10:24 PM

Tags for this Thread