尝试指向其他实例时发生NullPointerException

问题描述

在制作和检查combining.degree时,我尝试访问已编辑的多边形节点,但是却收到NullPointerException,如何解决此问题?我想使用在while循环中编辑过的poly,而不是在while循环之外设为null的poly。这是

    public static Node multiply(Node poly1,Node poly2) {
    Node poly3=poly1;
    Node poly4=poly2;
    Node poly=null;
    while (poly3!=null)
    {
        while(poly4!=null)
        {
            float x;
            int y;
            x=poly3.term.coeff*poly4.term.coeff;
            y=poly3.term.degree*poly4.term.degree;
            poly=new Node(x,y,poly);
            poly4=poly4.next;
        }
        poly4=poly2;
        poly3=poly3.next;
    }
    
    Node finalpoly=null;
    int i=poly.term.degree;
    float csum=0;
    Node combining = poly;
    while (i>=combining.term.degree)
    {
        while (combining!=null)
        {
            if (i==combining.term.degree)
            {
                csum+=combining.term.coeff;
            }
            combining=combining.next;
        }
        if (csum!=0)
        {
            finalpoly = new Node(csum,i,finalpoly);
        }
        i--;
    }
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...