1 / 6

EM-406 Java

Tip Bilgisi & Reflection. EM-406 Java. Motivasyon. Farklı şekillerde tutulan objelerin asıl tipleri Uzaktan Kumanda aslında neyi kontrol ediyor? Kesin olmayan tip dönüşümü (downcast) Direk tip öğrenme (Reflection API). Class classı. Class objesi Her class kendi hakkındaki bilgileri tutar

manon
Télécharger la présentation

EM-406 Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tip Bilgisi & Reflection EM-406 Java

  2. Motivasyon • Farklı şekillerde tutulan objelerin asıl tipleri • Uzaktan Kumanda aslında neyi kontrol ediyor? • Kesin olmayan tip dönüşümü (downcast) • Direk tip öğrenme (Reflection API)

  3. Class classı • Class objesi • Her class kendi hakkındaki bilgileri tutar • Shape.class • Class.forName(“Shape”)

  4. Tip Belirleme • Eldeki referans tipini değiştirmek alt tipe aktarmak • Shape sh = new Triangle(); • Triangle t = (Triangle)sh; • () ile yapılan işlem hatalıysa Exception atılır • instanceof gerekli bilgiyi sağlayabilir • if (t instanceof Triangle){…} • Class.isInstance() • t.getClass()

  5. Class işlemleri • Class.getInterfaces() • Class.getSuperclass() • Class.newInstance() • Class.getName() • …

  6. Reflection • Bazen çalışan obje hakkında hiçbir bilgi olmayabilir (JavaBeans, RMI) • java.lang.reflect paketi • Field, Method, Constructor • Field.get() Field.set() Method.call() • Reflection derleme zamanında olmayan çalışma zamanında olan .class lar ile ilgilenir

More Related