Created
September 20, 2020 17:12
-
-
Save mrnirva/4b2a5d2afd1ed91a4cfb20b3571f9b40 to your computer and use it in GitHub Desktop.
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