Results 1 to 3 of 3
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default printing out months

    how do i get these months listed on new lines?:

    Java Code:
    while (in.hasNext()) {
    			// This will get the next piece of text (or month name)
    				month = in.next();
    				num1 = in.nextInt();
    				num2 = in.nextInt();
    						
    				// This removes the comma in the month
    				for (i=0; i < (month.length()-1); i++) {
    					curChar = month.charAt(i);
    					chars = chars + curChar;
    				}
    				month = chars;
    								
    		}
    		
    		System.out.print(month);

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    System.out.print just prints to the console.

    System.out.println prints to the console, and adds a \n character at the end. Try using this one instead (on your last line).

  3. #3
    Ryan10 is offline Senior Member
    Join Date
    Mar 2011
    Posts
    144
    Rep Power
    0

    Default

    Zack said it all..System.out.println is specifically used to print "lines"

Similar Threads

  1. Replies: 4
    Last Post: 05-23-2011, 12:46 AM
  2. Replies: 2
    Last Post: 12-29-2010, 07:30 AM
  3. Need SCJP 5 Voucher with 1 or 2 months validity
    By rajeshtech in forum Java Certification
    Replies: 0
    Last Post: 10-21-2009, 08:12 AM
  4. Need SCJP voucher with 6 Months Validity
    By nphariharan in forum Java Certification
    Replies: 2
    Last Post: 07-29-2009, 08:11 PM
  5. Displaying 12 calendar months?
    By jaydubya in forum New To Java
    Replies: 3
    Last Post: 09-16-2008, 07:28 AM

Posting Permissions

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