Results 1 to 4 of 4
  1. #1
    relith is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default write line multiple times

    Hey all,

    I am brand new to java, but not to programming.


    I want to write a line multiple times, like 5, and each line to end with a newline.

    How would I do this. So far the only thing i know how to do is the basic helloworld thing.

    I would like to learn how to do this, i am not looking for someone to just give me the code, but to explain to me how the code work.

    Thanks in advance. :)


    EDIT: ok after a bit of messing around I got it to print 5 lines.

    here is my code, to show that im not trying to be a slacker. :P

    Java Code:
    class Exercise1_2
    {
    	public static void main(String args[])
    	{
    	int[] a={1,2,3,4,5};
    	for(int i : a){System.out.println("Welcome To Java");}
    	}
    }
    How would i get it to to end each line with a new line?

    NEW EDIT:
    Java Code:
    class Exercise1_2
    {
    	public static void main(String args[])
    	{
    	int[] a={1,2,3,4,5};
    	for(int i : a){System.out.println("Welcome To Java\n");}
    	}
    }
    OK so here is my new code. This is all for a class, and when i submit the code online it says that I got it wrong.

    here are the errors i am getting.

    Java Code:
     [5] => Testing Exercise1_2.java Round 0 : its not okay
        [6] => diff side by side difference, suppress common lines first 130 Characters....
        [7] => Welcome To Java						      |	Welcome to Java
        [8] => Welcome To Java						      |	Welcome to Java
        [9] => Welcome To Java						      |	Welcome to Java
        [10] => Welcome To Java						      |	Welcome to Java
        [11] => Welcome To Java						      |	Welcome to Java
        [12] => Character Dump Your Output...
        [13] => 0000000   W   e   l   c   o   m   e       T   o       J   a   v   a  \n
        [14] => *
        [15] => 0000120
        [16] => Character Dump Solution...
        [17] => 0000000   W   e   l   c   o   m   e       t   o       J   a   v   a  \n
        [18] => *
        [19] => 0000120
        [20] => 0 out of 1 Percentage 0
    I do not understand what it is saying to me.

    any and all help will be appreciated. :)

    Relith
    Last edited by relith; 10-27-2010 at 05:31 AM.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by relith View Post
    Java Code:
     [5] => Testing Exercise1_2.java Round 0 : its not okay
        [6] => diff side by side difference, suppress common lines first 130 Characters....
        [7] => Welcome To Java						      |	Welcome to Java
        [8] => Welcome To Java						      |	Welcome to Java
        [9] => Welcome To Java						      |	Welcome to Java
        [10] => Welcome To Java						      |	Welcome to Java
        [11] => Welcome To Java						      |	Welcome to Java
        [12] => Character Dump Your Output...
        [13] => 0000000   W   e   l   c   o   m   e       T   o       J   a   v   a  \n
        [14] => *
        [15] => 0000120
        [16] => Character Dump Solution...
        [17] => 0000000   W   e   l   c   o   m   e       t   o       J   a   v   a  \n
        [18] => *
        [19] => 0000120
        [20] => 0 out of 1 Percentage 0
    I do not understand what it is saying to me.
    I do; that stupid program tries to tell you that you have to write 'to' with a lowercase 't', not an uppercase 'T' as in 'To'.

    kind regards,

    Jos

  3. #3
    relith is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default

    oh...wow. well i feel like an idiot.
    didnt even bother looking at the String comparisons.

    thanks for helping me man. :)

    i shall be back with more questions.
    but before i ask all of those is there a good sticky of commands and how to use them on this site, specifically directed towards newbs like me?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    In ascending order of sophistication --
    The Java™ Tutorials
    Java Platform SE 6
    The Java Language Specification, Third Edition - TOC

    Note that Java doesn't have 'commands' -- there are statements and method calls.

    db

Similar Threads

  1. Issue with saving multiple times to a variable
    By sidd0123 in forum New To Java
    Replies: 3
    Last Post: 06-06-2010, 02:02 AM
  2. Write a Program that reads two times in military format
    By HPcompaq256 in forum New To Java
    Replies: 10
    Last Post: 02-26-2010, 04:38 AM
  3. calling action class multiple times
    By sindhu_shiva in forum Web Frameworks
    Replies: 0
    Last Post: 08-07-2009, 02:44 PM
  4. Playing an AudioInputStream multiple times
    By pmgallardo in forum Advanced Java
    Replies: 6
    Last Post: 03-09-2009, 04:29 PM
  5. Write to line in file
    By blackstormattack in forum New To Java
    Replies: 3
    Last Post: 03-09-2009, 12:59 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
  •