Results 1 to 3 of 3
  1. #1
    kingfisher is offline Member
    Join Date
    Oct 2015
    Posts
    7
    Rep Power
    0

    Default A small doubt in compiling

    Hello everyone,

    Am new to this forum and new to java too. While working on basic java program, I had doubt. The code I wrote was
    Java Code:
    public class displaypatternmessage{
    	public static void main(String[] args){
    	System.out.println("   J     A    V      V   A");
            System.out.println("   J    A A    V   V   A A");
            System.out.println("J  J   AAAAA  V V  AAAAA");
            System.out.println("J  J  A       A   V  A        A ");
    
             }
             }
    The output is
    Java Code:
      J     A     V       V   A
      J    A A    V     V  A  A
    J J   AAAA    V  V  AAAAA
    J J  A      A     V  A        A
    If I write code in this way,
    Java Code:
    public class displaypatternmessage{
    	public static void main(String[] args){
    	System.out.println("   J     A    V      V   A
                                          J    A A    V   V   A A
                                      J  J   AAAAA  V V  AAAAA
                                      J  J  A       A   V  A        A ");
    
             }
             }
    Why can't the compiler atleast display output "J A V V A J A A V V.. etc till the end of the letters need to be displayed.
    Does it only compile line by line? or Is it depending on the JDK?
    Last edited by JosAH; 10-01-2015 at 08:29 AM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: A small doubt in compiling

    A literal string may not span multiple lines (i.e. both the opening and closing quotes need to be on the same line); so this is correct:

    "hello"+
    "world"

    but this isn't:

    "hello
    world"

    Note that in my first example I concatenated two literal strings with the + operator. This retriction is just a compiler thingy ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    kingfisher is offline Member
    Join Date
    Oct 2015
    Posts
    7
    Rep Power
    0

    Default Re: A small doubt in compiling

    Hello Jos,


    That helped. Thank you for your reply.

Similar Threads

  1. JFilechooser small doubt, Text in pdf
    By sandeep43 in forum New To Java
    Replies: 8
    Last Post: 08-05-2011, 09:31 AM
  2. A small doubt
    By ranganathan in forum New To Java
    Replies: 5
    Last Post: 02-19-2010, 06:18 AM
  3. small doubt
    By ravi kumar in forum Java Software
    Replies: 1
    Last Post: 08-02-2009, 03:50 PM
  4. doubt
    By shaju_inspira in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-18-2008, 08:38 AM
  5. doubt in jms
    By veena in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 01-05-2008, 01:42 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
  •