Skip to content

关于stack有点疑问 #3

Description

@bulusite

我在calculatePostfixValue类中看到的一段

查看来自后端架构师技术图谱 的 栈

         //postifx = "1392-*+9+";
         char ch=postfix.charAt(i);
          if (ch>='0' && ch<='9')
          {
              result=0;
              while (ch!=' ')
              {
                  //将整数字符转为整数值ch=90
                  result = result*10 + Integer.parseInt(ch+"");
                  i++;
                  ch = postfix.charAt(i);
              }
              i++;
              stack.push(result);//操作数入栈
          }

这里的Integer.parseInt(ch+"");不会报错?
这里while 里面的ch = postfix.charAt(i);,不是会读取到操作符吗
result*10这个也没明白

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions