title: How to call a method from another method within same class in java
body: <p>I have two methods in the same class, the first method is<code>getEventByEventId</code> and the second method is <code>addEventUserRealtionMapping</code>. I need to call the <code>getEventByEventId</code> method from the <code>addEventUserRelationMapping</code> method. How can I get that done? </p>
  
  <pre><code>public EventBO getEventByEventId(long eventId) throws UserServiceException {
          try {
              EventDO eventDO = eventDAOImpl.getEventByEventId(eventId);
              EventBO eventBO = mapper.mapEventDOToBO(eventDO, new EventBO());
              return eventBO;
          } catch (UserDataException uExp) {
              throw new UserServiceException("Error while getting event for event id   " + eventId, uExp);
          }
      }
  
  public int addEventUserRealtionMapping(ArrayList&lt;UserBO&gt; userBOs, long eventId) throws UserServiceException {
  
          List&lt;EventUserRelationDO&gt; totalAddedCount;
          ArrayList&lt;UserDO&gt; userDOs = new ArrayList&lt;&gt;();
          try {
              for (UserBO userBO : userBOs) {
                  UserDO userDO = mapper.mapUserBOToDO(userBO, new UserDO());
                  userDOs.add(userDO);
              }
              EventBO eventBO =new EventBO();
              eventBO =getEventByEventId(eventId);//I am try that while call method1 but it doesn't work
              MessageBO messageBO = new MessageBO();
              messageBO.setEventId(eventBO.getEventId());
              messageBO.setEventTitle(eventBO.getText());
              messageBO.setMessage(eventBO.getText());
              messageBO.setRingeeUserId(eventBO.getRingeeUserId());
              messageBO.setMessageType(IRingeeConstants.MESSAGE_TYPE_INVITATION);
              totalAddedCount = eventDAOImpl.addEventUserRelationMapping(userDOs, eventId);
              if (totalAddedCount.size() == userDOs.size()) {
                  manageMessageService.sendMessageToGroup(userBOs, messageBO);
              }
          } catch (UserDataException dExp) {
              throw new UserServiceException(" exception while adding user relationship for eventId " + eventId, dExp);
          }
          return totalAddedCount.size();
      }
  </code></pre>