Questions tagged «scjp»

7
Java标识符中的“连接字符”是什么?
我正在阅读SCJP,对此行有疑问: 标识符必须以字母,货币字符($)或下划线(_)之类的连接字符开头。标识符不能以数字开头! 它指出有效的标识符名称可以以下划线之类的连接字符开头。我以为下划线是唯一有效的选择?还有哪些其他连接字符?
208 java  unicode  identifier  scjp 

9
为什么Double.NaN == Double.NaN返回false?
我刚刚研究OCPJP问题,发现了这个奇怪的代码: public static void main(String a[]) { System.out.println(Double.NaN==Double.NaN); System.out.println(Double.NaN!=Double.NaN); } 运行代码时,我得到: false true false当我们比较看起来彼此相同的两件事时,输出如何?什么NaN意思
155 java  floating-point  nan  scjp  ocpjp 

2
id = 1-id是原子吗?
在OCP Java SE 6程序员实践考试的第291页中,问题25: public class Stone implements Runnable { static int id = 1; public void run() { id = 1 - id; if (id == 0) pick(); else release(); } private static synchronized void pick() { System.out.print("P "); System.out.print("Q "); } private synchronized void release() { System.out.print("R "); …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.