code: public void solve(DenseMatrix B) {
          if (B.nrows() != L.nrows()) {
              throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x %d", L.nrows(), L.ncols(), B.nrows(), B.ncols()));
          }
  
          int n = B.nrows();
          int nrhs = B.ncols();
  
          // Solve L*Y = B;
          for (int k = 0; k < n; k++) {
              for (int j = 0; j < nrhs; j++) {
                  for (int i = 0; i < k; i++) {
                      B.sub(k, j, B.get(i, j) * L.get(k, i));
                  }
                  B.div(k, j, L.get(k, k));
              }
          }
  
          // Solve L'*X = Y;
          for (int k = n - 1; k >= 0; k--) {
              for (int j = 0; j < nrhs; j++) {
                  for (int i = k + 1; i < n; i++) {
                      B.sub(k, j, B.get(i, j) * L.get(i, k));
                  }
                  B.div(k, j, L.get(k, k));
              }
          }
      }
docs: Solve the linear system A * X = B. On output, B will be overwritten with
  the solution matrix.
  @param  B   the right hand side of linear systems.