title: How can i return multiple getters from my method?
body: <p>I have made a method that is requesting a column from my MySQL database. Fortunately this is working, but i am trying to acces the return value. Because i want to acces the getters and setters for Voedingsmiddel. A new Voedingsmiddel is created inside the method and later returned. The values of the database are assigned as the attributes of the voedingsmiddel. This method is created in my Database class and i am trying to acces it within another class.</p>
  
  <p>If i am trying to acces voedingsmiddel outside of the method, it is nog giving me an object, instead it is giving me the datalocation Voedingsmiddel@6f7fd0e6. </p>
  
  <ol>
  <li><p>I was able to get some of the result i am trying to get. I achieved it by changing public Voedingsmiddel getVoedingsmiddelBijId to public double getVoedingsmiddelBijId. I also changed return voedingsmiddel; into voedingsmiddel.getCalorieen; So i was able to get 1 of the getters.</p></li>
  <li><p>By calling the method Database.getVoedingsmiddelBijId(int).getCalorieen();
  Intellij is telling me the following (Result of'Voedingsmiddel.getCalorieen()' is ignored).</p>
  
  <p><pre> public Voedingsmiddel getVoedingsmiddelBijId(int idVoedingsmiddel) {
          Voedingsmiddel voedingsmiddel = new Voedingsmiddel("", 0, 0,0,0,0);
          try {
              String query = "select * from voedingsmiddel where idVoedingsmiddel = ?";
              PreparedStatement preparedStatement = myCon.prepareStatement(query);
              preparedStatement.setInt(1, idVoedingsmiddel);
              myRes = preparedStatement.executeQuery();
              while (myRes.next()) {
                  int idvoedingsmiddel = myRes.getInt("idVoedingsmiddel");
                  String naam = myRes.getString("naam");
                  int gram = myRes.getInt("gram");
                  double calorieen = myRes.getDouble("calorieën");
                  double koolhydraten = myRes.getDouble("koolhydraten");
                  double eiwitten = myRes.getDouble("eiwitten");
                  double vetten = myRes.getDouble("vetten");</p>
  
  <code>            voedingsmiddel = new Voedingsmiddel(naam, gram, calorieen, koolhydraten, eiwitten, vetten);
  System.out.println("idVoedingsmiddel " + idvoedingsmiddel  + " naam " + naam + " gram " + gram + " calorieën " + calorieen +  " koolhydraten " + koolhydraten + " eiwitten " + eiwitten + " vetten " + vetten);
          }
      } catch (Exception exc) {
          exc.printStackTrace();
          System.out.println("Error: " + exc);
      }
      return voedingsmiddel;
  }
  </code></pre></li>
  </ol>
  
  <p>First of all, i would really appreciate it, if someone could explain me what i am doing wrong. Also a solution to the problem would be more then welcome!</p>
  
  <p>The expected result is that the return value of the method would be an object instead of what i think is a datalocation. So i can call the getters and setters for that object. </p>
  
  <p>I have a history of posting too much code and not enough information. So i hope this is better, if not feel free to correct me.</p>