Java Reflection Cheat Sheet: http://goo.gl/wqfPk Welcome to my Java Reflection Video Tutorial! I’ve been asked many times to cover Java Reflection lately and …

source

31 COMMENTS

  1. Everything up to min15 is fine. After that i get issues. This is my output in min18:

    java.lang.NoSuchMethodException: UfoEnemyShip.<init>(EnemyShipFactory)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getConstructor(Unknown Source)
    at ReflectionDemo.main(ReflectionDemo.java:78)
    Exception in thread "main" java.lang.NullPointerException
    at ReflectionDemo.main(ReflectionDemo.java:87)

    You can see my code here: https://gist.github.com/CobNik/08293f46036574bdcae0ee1a4f5c3d3e

    If someone can help i would be very grateful. Thanks.

  2. Is it possible to get the name of a variable such as this:

    class EnemyShip{

    };

    main()
    {
    EnemyShip starBlaster;

    /// I want to now print out starBlaster because that's the name of the variable. But instead I get the name of the class which is EnemyShip.

    starBlaster.Class.getName() returns "EnemyShip" because that's the class's name, but I want it to return "startBlaster" because that's what I called the variable.
    }

  3. Started working on a 3rd year Assignment that required Reflection basics to grab infos out of various files. I was having really hard time as to where to start because the concept was pretty vague to me and you just taught me the whole idea in 30 min video . Thanks mate really helped alot ?

  4. before i watch this because i'm kinda in a hurry ,,, does this allow me to write -> compile -> invoke classes/methods during run time ?? please quick answer … because i'm very busy with a lot of things … i don't wanna waste 24 min if it's not the thing i want … btw i do love all your videos Derek you are amazing <3

LEAVE A REPLY

Please enter your comment!
Please enter your name here