java - Can a class call another function in a class without the firstclass needing to know the class that is it -


so might have worded question badly try explain mean. have game server interfaces unity written in java , wandering if there better way of handling received tcp stream data. suggested use dynamic packet handling improvement still requires handler have specific handle code each of different packet types.

so wandering possible have received data object has code in has method name of handle packet , have handler not need know type of packet/class received , have call handle packet method. advice appreciated.

if has been answered before sorry didn't know called google searched not helping.

i use polymorphism. need create base type called packet , have other packet types inherit packet. packet class have method called handle of inherited classes too. way can call handle types of packets , different types of packets can handle differently. see this article oracle more information on inheritance in java.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -