According to the lecture, "A constructor is similar to the initialize method, with just two differences:
1. The name of the constructor is the same as the class name (instead of initialize).
2. A constructor has no type (no type is indicated)."
package com.codegym.task.task05.task0516;
/*
You can't buy friends
*/
public class Friend {
private String name;
private int age;
private char sex;
public void Friend(String name){
this.name = name;
this.age = 24;
this.sex = 'M';
}
public void Friend(String name, int age){
this.name = name;
this.age = age;
this.sex = 'F';
}
public void Friend(String name, int age, char sex){
this.name = name;
this.age = age;
this.sex = sex;
}
public static void main(String[] args) {
}
}