为什么我的电脑在使用String(char [] ch)代码时发出嘟嘟声?

问题描述:

我使用JCreator的,它编译罚款,但在运行代码为什么我的电脑在使用String(char [] ch)代码时发出嘟嘟声?

class StringDemo { 

public static void main(String[]args){ 

    char[]arr={7}; 

    String s1= new String(arr); 
    System.out.println(s1); //prints nothing 

    } 
} 
+1

该特定字符必须发出噪音:) – notyou

+0

不一定。在我的笔记本电脑上,它只是打印没有声音的Unicode替换字符 。 –

+0

尝试'char [] arr = {'7'};' – Naxos84

ASCII/Unicode字符7是'bell' code发出蜂鸣声。因此,当您打印它时,控制台被配置为生成声音。

+0

好!我从未想过它。非常感谢。 –