gpt4 book ai didi

java - 调试字符串和表示字符串的约定

转载 作者:行者123 更新时间:2023-12-02 09:24:00 24 4
gpt4 key购买 nike

嗨,我正在编写一个可满足性检查器,并且我有一个 Literal
我需要:

  • 一种显示 Literal 详细信息/状态的方法
  • 一种用于显示原始用户输入的Literal的方法。

    但只有一个 toString 方法。我应该将哪一个放入 toString 中,并且应该为哪一个创建新方法?这类东西有约定吗?如果是的话有什么原因吗?

    更新
    我的详细信息/状态字符串如下所示:

    String.format("Full literal: %s, raw literal: %s, negated: %s, " +
    "tautology: %s, contradiction: %s, assigned: %s",
    this.fullLiteral, this.rawLiteral,
    this.isNegated, this.isTautology,
    this.isContradiction, this.isAssigned ? this.truthValue : "null");

    我的原始文字字符串如下所示:

    return String.format("Raw literal: %s", this.rawLiteral);
  • 最佳答案

    toString()

    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

    这可能支持我关于使用 toString() 获取详细字符串的评论(因此有不同的方法,例如 getRaw() 用于获取原始数据)

    关于java - 调试字符串和表示字符串的约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58474367/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com