That is to cast object x of type Object
which is superclass of all the classes in java to AbstractGuiTest
This happens quite frequently in Java because of inheritance.
So, in your case AbstractGuiTest
is subclass of Object
class or in other words inherits from Object
. So, by using this AbstractGuiTest currentCase = (AbstractGuiTest)x;
you are making x
of type AbstractGuiTest
.
If you use this typecasting on classes which are not in the same class hierarchy, you will get ClassCastException
Another example could be:
Animal is superClass and Dog is its subclass
public class Animal{
//some code goes in here
}
public class Dog extends Animal{
//some code goes in here
}
Now, you can use this syntax:
Animal a = new Dog();
Dog d = (Dog) a;
You should read more on inheritance in java to make this concept clear.