Last active
December 19, 2021 10:06
-
-
Save sunmeat/95e0d35f2845398f3841 to your computer and use it in GitHub Desktop.
missing default ctor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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