Презентация Java Reflection: A Basic Introduction онлайн

На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Java Reflection: A Basic Introduction абсолютно бесплатно. Урок-презентация на эту тему содержит всего 10 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.



Оцените!
Оцените презентацию от 1 до 5 баллов!
  • Тип файла:
    ppt / pptx (powerpoint)
  • Всего слайдов:
    10 слайдов
  • Для класса:
    1,2,3,4,5,6,7,8,9,10,11
  • Размер файла:
    101.00 kB
  • Просмотров:
    64
  • Скачиваний:
    0
  • Автор:
    неизвестен



Слайды и текст к этой презентации:

№1 слайд
Java Reflection A Basic
Содержание слайда: Java Reflection: A Basic Introduction Reflection - This mechanism research data about the program during its execution. Reflection allows us to investigate the information about the fields , methods and constructors of classes. Reflection in Java by using Java Reflection API. This API consists of classes java.lang package and java.lang.reflect.

№2 слайд
Using Java Reflection API
Содержание слайда: Using Java Reflection API interface , you can do the following: Determine the object class . Get information about modifiers classes , fields, methods, constructors, and superclasses . To find out what constants and methods belong to the interface. Create an instance of a class whose name is not known until runtime. Get and set the value of the object. Call the object method. Create a new array , the size and type of components which are not known until runtime programs.

№3 слайд
Getting the object class type
Содержание слайда: Getting the object class type MyClass a = new MyClass(); Class aclass = a.getClass(); If we have an instance of the Class object we can get all possible information about this class , and even perform operations on it .The above method getClass () are often useful when there is then an object instance , but do not know what class this instance . If we have a class that is known at compile time type, get a copy of the class is even easier . Class aclass = MyClass.class; Class iclass = Integer.class;

№4 слайд
Getting the class name Class
Содержание слайда: Getting the class name Class c = myObject.getClass(); String s = c.getName(); An object of type String, returned by getName (), will contain the fully qualified name of the class , that is, if myObject is the object type Integer, the result is the type java.lang.Integer.

№5 слайд
Research modifiers class
Содержание слайда: Research modifiers class Class c = obj.getClass(); int mods = c.getModifiers(); if (Modifier.isPublic(mods)) { System.out.println("public"); } if (Modifier.isAbstract(mods)) { System.out.println("abstract"); } if (Modifier.isFinal(mods)) { System.out.println("final"); }

№6 слайд
Finding the superclass Class
Содержание слайда: Finding the superclass Class c = myObj.getClass(); Class superclass = c.getSuperclass(); To get all parent superclasses , you need to recursively call the method getSuperclass ().

№7 слайд
Research information on the
Содержание слайда: Research information on the method , the method call . Class c = obj.getClass(); Method[] methods = c.getMethods(); for (Method method : methods) { System.out.println("Name: " + method.getName()); System.out.println("Returned type: " + method.getReturnType().getName()); Class[] paramTypes = method.getParameterTypes(); System.out.print("Params's types: "); for (Class paramType : paramTypes) { System.out.print(" " + paramType.getName()); } System.out.println(); }

№8 слайд
Research information on the
Содержание слайда: Research information on the method , the method call . Methods getMethod () and getMethods () return only the public methods , in order to get all the methods of the class regardless of the type of access you need vospolzovatsya methods getDeclaredMethod () and getDeclaredMethods (), which work just as well as their analogues (getMethod () and getMethods ()). Java Reflection Api interface allows you to dynamically invoke a method , even if at the time of compilation of this method is the name of the unknown ( Class method names can be obtained by getMethods () or getDeclaredMethods ()).

№9 слайд
Research information on the
Содержание слайда: Research information on the method , the method call . Class c = obj.getClass(); Class[] paramTypes = new Class[] { String.class, int.class }; Method method = c.getMethod("getCalculateRating", paramTypes); Object[] args = new Object[] { new String("First Calculate"), new Integer(10) }; Double d = (Double) method.invoke(obj, args);

№10 слайд
Download and dynamically
Содержание слайда: Download and dynamically create an instance of the class Class c = Class.forName("Test"); Object obj = c.newInstance(); Test test = (Test) obj; With the use of Class.forName () and newInstance () Class object can dynamically load and instantiate the class when the class name is not known until runtime. newInstance () method returns a generic duplicate objects of type Object, so the last line we give the returned object of the type we need.

Скачать все slide презентации Java Reflection: A Basic Introduction одним архивом: