Java copy objects 🖨️

preview_player
Показать описание
Java copy object cloning copy constructor

#Java #copy #objects
Рекомендации по теме
Комментарии
Автор


public class Main {

public static void main(String[] args) {


Car car1 = new Car("Chevrolet", "Camaro", 2021);
//Car car2 = new Car("Ford", "Mustang", 2022);
//car2.copy(car1);
Car car2 = new Car(car1);

System.out.println(car1);
System.out.println(car2);
System.out.println();



System.out.println();




}
}

public class Car {


private String make;
private String model;
private int year;

Car(String make, String model, int year){
this.setMake(make);
this.setModel(model);
this.setYear(year);
}

Car(Car x){
this.copy(x);
}

public String getMake() {
return make;
}

public String getModel() {
return model;
}

public int getYear() {
return year;
}

public void setMake(String make) {
this.make = make;
}

public void setModel(String model) {
this.model = model;
}

public void setYear(int year) {
this.year = year;
}

public void copy(Car x) {
this.setMake(x.getMake());

this.setYear(x.getYear());
}

}

BroCodez
Автор

This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro

pavelkvasnicka
Автор

you really got style. you are changing lives Bro. I thank you from the bottom of my heart.

ibrahimylmaz
Автор

you're my dude buddy. nice voice-over, excellent video quality, and easy-to-follow content. God bless you.

odaakeenya
Автор

Absolutely easier after you explain everything. Thank you Bro! you save my day

mimvt
Автор

Man, I love your videos, you are so underrated (your videos should have more views)

juanestebanparraparra
Автор

bro..this is the best course in whole youtube

healer
Автор

Amazing video! I was looking for copying objects for so long.... thanks bro

theultimateamazing
Автор

Great explanation! Keep on the good work!

yahelbraun
Автор

Brilliant Brilliant explanation and exactly what I needed for my Pokemon game :)

Ballnose
Автор

Thank you Bro🤗How are you doing? This tutorial is great!

geneolo
welcome to shbcf.ru