인쇄하는 모든 콘텐츠에"노드 목록에"동일한 라인

0

질문

Im 초보자 및 난 작업 java 현재,나를 작성해야 한 줄에 방정식과 같은 5x^3+2 배^4+...콘텐츠를 사용하여 내부에 노드입니다.

여기에 내 노드:

public class Node {
    private Termo element;
    private Node next;
    
    public Node(){
        element = null;
        next= null;
    }
    
    public Node( Termo element, Node next){
        this.element= element;
        this.next= next;
    }
    
     public void setnext( Node next){
        this.next= next;
    }
    
    public Node getnext(){
        return proximo;
    } 
    
     public void setElement( Termo element){
        this.element= element;
    }
    
    public Termo getElement(){
        return element;
    }
    
    @Override
    public String toString(){
        return "Termo: " + getElement().getCoef() + "x^" +getElement().getExp();
    }
}

내 용어(는 객체로 계수와 지수)

private double coef;
private int exp;

public Termo() {
    coef=0;
    exp=0;
}

public Termo(double coef, int exp) {
    this.coef = coef;
    this.exp = exp;
}

public double  getCoef() {
    return coef;
}

public void setCoef(int coef) {
    this.coef = coef;
}

public int getExp() {
    return exp;
}

public void setExp(int exp) {
    this.exp = exp;
}

public Object getObject(){
    Termo obj = new Termo(this.coef, this.exp);
    return obj;
}

@Override
public String toString() {
    return coef + " " + exp;
}

내가 만든 인쇄하려면 이 방법 콘텐츠,하지만 난 그것에서 하나의 라인:

public void escrevePolinomio (Node lista){
        if(lista != null){
            System.out.println(lista.getElement().getCoef()+"x^"+lista.getElement().getExp());
            lista=lista.getnext();
            escrevePolinomio(lista);
        }
    }
java nodes printing
2021-11-23 15:10:34
1

최고의 응답

0

System.out.print()System.out.println():

public void escrevePolinomio (Node lista){
    if(lista != null){
        System.out.print(lista.getElement().getCoef()+"x^"+lista.getElement().getExp());
        lista=lista.getnext();
        escrevePolinomio(lista);
    }
}
2021-11-23 15:19:29

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................