加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

如何在Java中键入π(pi)?

发布时间:2020-12-15 00:58:04 所属栏目:Java 来源:网络整理
导读:Math API中是否有字符允许表示字符π? 解决方法 你甚至不需要使用Math API.在 Java源代码中, u03C0 相当于: π 你甚至可以在标识符中使用它;这两个是等效的 final String u03C0 = "u03C0";final String π = "π"; (正如规范所说: A Unicode escape of
Math API中是否有字符允许表示字符π?

解决方法

你甚至不需要使用Math API.在 Java源代码中,
u03C0

相当于:

π

你甚至可以在标识符中使用它;这两个是等效的

final String u03C0 = "u03C0";
final String π = "π";

(正如规范所说:

A Unicode escape of the form uxxxx,where xxxx is a hexadecimal value,represents the UTF-16 code unit whose encoding is xxxx. This translation step allows any program to be expressed using only ASCII characters.

见http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.2.)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读