Re: Java question

  • From: Dave <davidct1209@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 30 May 2010 17:00:12 -0700

You can write the calls to System.out.println in a single statement if
you simply concatenate the strings for each individual call to
System.out.println  using the "+" operator.

For example:
string s1, s2, s3, s4;

System.out.println(s1 + "\n" +
s2 + "\n" +
s3 + "\n" +
s4);


hth,
David

On 5/30/10, Gilbert Neiva <gneiva@xxxxxxx> wrote:
> I'm trying to write a program in Eclipse that quotes four lines from a poem,
> but I'm suppose to write the four lines in one output statement. I'm also
> suppose to put asterisks around the four lined quote. How would I do this
> all in one statement? The program I wrote is below.
>
> // Application HatchesTheEgg
> // This application will write
> // four lines from
> // Dr. Seuss's Horton's
> // Hatches the Egg
>
> import java.io.*; // Imports the java.io package
>
> public class HatchesTheEgg
> {
>  public static void main(String[] args)
>  {
>   final String phrase1 = "I meant";
>   final String phrase2 = "I said";
>   final String phrase3 = "an elephant's faithful";
>   final String phrase4 = "one hundred percent";
>   final String stars = "***************************";
>   System.out.println(stars);
>   System.out.println("* "+phrase1+" what "+phrase2+"     *");
>   System.out.println("* and "+phrase2+" what "+phrase1+" *");
>   System.out.println("* "+phrase3+"  *");
>   System.out.println("* "+phrase4+"     *");
>   System.out.print(stars);
>  }
> }
>
> Gilbert Neiva
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: