This file contains 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 sinifnesne; | |
public class SinifNesne { | |
public static void main(String[] args) { | |
// Seçtiğimiz rengi yapıcı metoda gönderiyoruz | |
Arac araba = new Arac("Mavi"); | |
System.out.println(araba.renk); | |
} | |
} | |
class Arac{ | |
public String renk; | |
/* | |
Yapıcı metodun parametresine gelen | |
sadece bir değişken. Biz bu değişkeni | |
alıp nesnemizin rengine eşitliyoruz | |
*/ | |
public Arac(String renk){ | |
this.renk = renk; | |
/* | |
İlgili nesnenin rengini yeni yollanan | |
renk ile değiştiriyoruz | |
this direkt olarak işlem yapılan nesneyi verir | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment