Можете объяснить как не в скобках значение записать, а через строку сослаться? Мой код который в // он не принимал, почему?
package com.javarush.task.task05.task0504;
/*
Трикотаж
*/
public class Solution {
public static void main(String[] args) {
Cat cat1 = new Cat("jorg", 2, 50, 5);
// cat1.name = "Jorg";
// cat1.age = 2;
// cat1.weight = 50;
// cat1.strength = 5;
Cat cat2 = new Cat("l",2,4,3);
// cat2.name = "Iop";
// cat2.age = 4;
// cat2.weight = 70;
// cat2.strength = 3;
Cat cat3 = new Cat("j",2,8,7);
// cat3.name = "Het";
// cat3.age = 7;
// cat3.weight = 30;
// cat3.strength = 7;
}
public static class Cat {
private String name;
private int age;
private int weight;
private int strength;
public Cat(String name, int age, int weight, int strength) {
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
}
}