Почему нельзя написать во так:
Cat cat1 = new Cat();
cat1.Cat("a1", 1, 1, 1); ?
Выдает ошибку
constructor Cat in class com.javarush.task.task05.task0504.Solution.Cat cannot be applied to given types; required: java.lang.String,int,int,int found: no arguments reason: actual and formal argument lists differ in length:
Solution.java, line: 10, column: 19
cannot find symbol symbol: method Cat(java.lang.String,int,int,int) location: variable cat1 of type com.javarush.task.task05.task0504.Solution.Cat:
Solution.java, line: 11, column: 12
package com.javarush.task.task05.task0504;
/*
Трикотаж
*/
public class Solution {
public static void main(String[] args) {
Cat cat1 = new Cat("a1", 1, 1, 1);
Cat cat2 = new Cat("a2", 2, 2, 2);
Cat cat3 = new Cat("a3", 3, 3, 3);
}
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;
}
}
}