Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Last active December 19, 2021 10:06
Show Gist options
  • Select an option

  • Save sunmeat/95e0d35f2845398f3841 to your computer and use it in GitHub Desktop.

Select an option

Save sunmeat/95e0d35f2845398f3841 to your computer and use it in GitHub Desktop.
missing default ctor
package com.alex.constructors;
class Person {
String name;
String surname;
int age;
Person(String n, String s, int a) {
name = n;
surname = s;
age = a;
}
void print() {
System.out.println(name + " " + surname + ", " + age + " лет.");
}
}
class Program {
public static void main(String[] args) {
Person a = new Person("Petr", "Petrov", 47);
Person b = new Person();
// constructor Person in class Person cannot be applied to given types;
// required: String,String,int
// found: no arguments
// reason: actual and formal argument lists differ in length
a.print();
b.print();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment