Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Error With \n

$
0
0
My homework assignment this three-line poem and I have to put them together and get each of the six combinations possible with named constants and escape sequences. I created a string for each line but how do I string them all together without getting them on the same line? I tried using \n but it gives me errors wherever I place it... I also don't know where to use a named constant in this code. This is what I have so far:

public class Lion {
 public static void main (String [] args)
  {
    String lineA = "I saw a wild yellow lion.";
    String lineB = "The wild yellow lion saw me.";
    String lineC = "Oh! What a terrifying experience!";
    String poem1 = lineA + lineB + lineC;
    System.out.printf(poem1);
  }
}


I know I have to create poems 2-6, but I figured this code was example enough. Thank you for any help or suggestions!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>