Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Parrot Information Display | Classes
Java Extended
course content

Kursusindhold

Java Extended

Java Extended

1. Deep Java Structure
2. Methods
3. String Advanced
4. Classes
5. Classes Advanced

book
Challenge: Parrot Information Display

Opgave

Swipe to start coding

Your task is to write a toString() method that will display all the information about the parrot.

  1. In the toString() method, use the return keyword to specify the output of the method.
  2. Start by creating a string, either using concatenation or string formatting, beginning with something like Parrot{.
  3. Add each field to the string, using + for concatenation, and include both the field name and its value (e.g., "name='" + name + "'").
  4. Separate each field with a comma and a space for better readability.
  5. End the string with a closing brace } to properly represent the object.
  6. Finally, return the formatted string from the toString() method.

Løsning

java

solution

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 9
toggle bottom row

book
Challenge: Parrot Information Display

Opgave

Swipe to start coding

Your task is to write a toString() method that will display all the information about the parrot.

  1. In the toString() method, use the return keyword to specify the output of the method.
  2. Start by creating a string, either using concatenation or string formatting, beginning with something like Parrot{.
  3. Add each field to the string, using + for concatenation, and include both the field name and its value (e.g., "name='" + name + "'").
  4. Separate each field with a comma and a space for better readability.
  5. End the string with a closing brace } to properly represent the object.
  6. Finally, return the formatted string from the toString() method.

Løsning

java

solution

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 9
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt