Results 1 to 2 of 2
  1. #1
    maas is offline Member
    Join Date
    Jul 2010
    Posts
    28
    Rep Power
    0

    Default Help in printing the result of the for loop

    Dear All,

    I am having a problem while writing this java for loop code. I am trying to print "NETProduct" a number of times which is depending on the passed "length" variable and to print after the word "NETProduct" the current value of the length + " ," and when it reached the last "NetProduct", it shoudn't produce "," after the "NETProduct" variable.
    As an example:

    Java Code:
    String sentence = "";
    int length = 4;
    for ( i = 1 ; i <= length ; i++)
    {
    sentence = "NETProduct" + i + ",";
    
    }
    So, what I am looking for is for the result:

    NETProduct1,NETProduct2,NETProduct3,NETProduct4

    and the result is in the same line.

    Can you please help

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default

    Have you run that code?
    Just asking, because we generally correct code people are having problems with. We don't generally provide solutions to problems.

Similar Threads

  1. Printer loop the same printing
    By kiki2009 in forum Advanced Java
    Replies: 2
    Last Post: 04-29-2011, 05:43 PM
  2. problem with if statement in while loop of result set
    By kishan.java in forum New To Java
    Replies: 6
    Last Post: 04-09-2011, 04:07 PM
  3. Printing a table with a for loop help
    By shroomiin in forum New To Java
    Replies: 2
    Last Post: 10-31-2009, 01:47 AM
  4. Printing a table with a for loop help
    By shroomiin in forum New To Java
    Replies: 1
    Last Post: 10-31-2009, 01:41 AM
  5. Problem printing inside FOR loop
    By cassysumandak in forum New To Java
    Replies: 1
    Last Post: 10-04-2009, 05:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •