go to previous page   go to home page   hear noise   go to next page

Answer:

Yes.


Many-line Comments

/* Program 1
Write out three lines of a poem.
The poem describes a single moment in time,
using 17 syllables.
*/

class Haiku
{
  public static void main ( String[] args )
  {
    System.out.println("On a withered branch" );
    System.out.println("A crow has just alighted:");
    System.out.println("Nightfall in autumn."); 
  }
}

Often you want to write a comment that spans several lines, as above.

With this style of comment, everything between the two characters /* and the two characters */ are ignored by the compiler.

The / and the * must not have any character between them. There can be many lines of comments between the /* pair and the */ pair.

The /* and the */ can start and stop anywhere on a line. Everything between the pair is a comment ignored by the compiler.


QUESTION 17:

Is the following correct?


class Haiku
{
  public static void main ( String[] args )
  {
    System.out.println /* print a line containing the following string */ ("On a withered branch" );
    System.out.println("A crow has just alighted:");
    System.out.println("Nightfall in autumn."); 
  }
}