The Poisson equation is solved in a rectangular prism of semiconductor with the boundary conditions commonly used in semiconductor device modeling. There is a planar heterojunction inside the prism. The finite difference formulation leading to a matrix of seven diagonals is used. The 3D version of the Stone's method is applied for the iterative solution of the matrix equation. The nonlinear dependence of the carrier concentration on the electrostatic potential is taken into account. The heterojunction is modeled by a potential jump. The advantages and limits of the method is presented.