It requires solving a problem that is very easy to implement in PHP, but it is unclear how - in Java (talking about logic). I need to create an instance of one of the 2 objects for later access to its properties / methods. What kind of object - it depends on. conditions For Java, a similar solution:
if("Заказчик".equals(uStatus)){ Customers UserObj = new Customers(); }else{ if("Диспетчер".equals(uStatus)){ Bosses UserObj = new Bosses(); } } Content = UserObj.getForm();
... does not work, because outside the condition, it does not see the UserObj object. Execute each code variant within all blocks depending on the condition:
if("Заказчик".equals(uStatus)){ Customers UserObj = new Customers(); Content = UserObj.getForm(); }else{ if("Диспетчер".equals(uStatus)){ Bosses UserObj = new Bosses(); Content = UserObj.getForm(); } }
... hardly rational. What could be the right solution in terms of the concept of Java? I understand that for those who write not her, the question is elementary. I would be very grateful for the clarification.