title: How to return value inside a lambda
body: <p>I am new with java 8 and lambda and I don't know what should I do for returning value inside a lambda .
  I tried this code but return null value but in the logs the token is logged.
  also i tried static value but it didn't work. i want to return this value in another java class and use it .</p>
  
  <pre class="lang-java prettyprint-override"><code> public  String GetToken(Context context,String user_name,String password) throws JSONException {
          RequestQueue requestQueue= Volley.newRequestQueue(context);
          JSONObject jsonBody = new JSONObject();
          jsonBody.put("user_name", user_name);
          jsonBody.put("password", password);
          final String mRequestBody = jsonBody.toString();
  
          StringRequest request = new StringRequest(
                      Request.Method.POST,
                      url,
                      response -&gt; {
                          try {
                              JSONObject jso = new JSONObject(response);
                              String token=jso.getString("token");
                              result=token;
                          } catch (JSONException e) {
                              e.printStackTrace();
                              Log.i("GetTokene",e.toString());
                              result=e.toString();
                          }
                      },
                      error -&gt; {
                          Log.i("GetTokenE",error.toString());
                           result=error.toString();
                      }
              ) {
                  @Override
                  public String getBodyContentType() {
                      return "application/json";
                  }
                  @Override
                  public byte[] getBody() {
                      try {
                          return mRequestBody == null ? null : mRequestBody.getBytes("utf-8");
                      } catch (UnsupportedEncodingException uee) {
                          // VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
                          return null;
                      }
                  }              
              };
  
              requestQueue.add(request);
              return result;
          }
  </code></pre>