JAVA · ОСНОВЫ · LESSON 19
Drawing and object
Class and object · about 16 minutes
Learning with progressRead the summary for free. To save the work, log in to the account.
Type the code yourself
Type an example manually. Check the signs and brackets.
public class Main {
public static void main(String[] args) {
Cat cat = new Cat();
cat.name = "Рыжик";
System.out.println(cat.name);
}
}
class Cat {
String name;
}Open the editor for class workSolve it yourself
Create a Dog class with the String name field. In main, create a dog object, put the word «Бим» in its name, and output this field.
The answer is hidden. Use similar examples from the lesson notes.
Opening up your homework