Java BankAccount Class — Code Review prompt
Business54.1K
审阅一段 Java 银行账户类,指出问题并给改进建议
Review a Java bank-account class, flag issues, and suggest improvements.
Full prompt
请审阅下面这段 Java 银行账户类(BankAccount,含存款、取款、查询余额、关闭账户,以及一个重写的 finalize)。指出其中的问题并给出改进建议,重点关注:1)用 double 表示金额的精度隐患(建议改用 BigDecimal 或以分为单位的整数);2)重写 finalize() 的弊端(已弃用、不可靠、不应用于资源清理,建议改用 try-with-resources / Cleaner);3)线程安全(并发存取时余额竞态);4)输入校验(负数金额、空账户信息);5)封装与不可变性(哪些字段应设为 final、如何提供只读视图)。 请给出:问题清单(按严重度排序)、每条的原因说明、以及重构后的示例代码。待审阅代码: ____(在此粘贴你的代码)
Fill in the blanks, then copy
How to use this prompt
- 1Copy the full prompt below
- 2Replace the [____] placeholders with your specifics
- 3Paste into DeepSeek / Claude / ChatGPT to run
Related Business prompts
AI Agent Security Evaluation Checklist
Build a privacy and security evaluation checklist for AI agent types.
Tumor Medical Industry Solution Business Plan
Generate a structured business plan for an oncology medical startup.
Orchestration Agent (PowerPlatformSupervisor)
Route user requests deterministically to the single best sub-agent.