oop « cast « Java Data Type Q&A





1. How can I avoid code duplication with many small classes?    stackoverflow.com

I have different classes called English, Spanish, French, etc.:

Class English{
    String name = "English";
    String alias = "ENG";
}

Class French{
    String name = ...

2. What type should I cast to?    stackoverflow.com

I have a form class with a method:

IText getSearchField()
The IText interface is something implemented by a subclass of JTextField called MyTextField. For reasons beyond my control, I cannot get the control from ...

3. Why casting direction is big to small in primitive types and small to big with objects?    stackoverflow.com

In Java we need casting when converting double(big in memory size) to Integer (smaller in memory size)

int x = (int) 4.3;
But in case of objects if parent class is "Mammal"(small ...

4. OO-design with casting / structure issue    stackoverflow.com

I have a class which does operations on the database, but I want to keep it as general and abstract as possible, thus by Object return types. Here's an example method of ...