@sanoj27, A friendly advise. Before you raise question in forum. Always tried to provide details. Like what you tried so far.
In additional note the question you are asking has nothing to do with Appium. Its basic question in Java. So try to find out question your self like why you are not able to cast? am i follow correct class hierarchy or what??
So i means to say always narrow down approach and first try to find solution your self. i believe thats is the only ways to learning.
People in this forum are very helpful and kind, and always try to help other. But provide your findings and details before you shoot your questions.
Your “driver” is a reference to an object of type AppiumDriver. AppiumDriver does not inherit from NetworkConnection, so you should rightfully get a casting exception. Check the Javadocs to see if there is a way for you to find the functionality you need. Hint: If this is an Android test, look at the documentation for AndroidDriver.