对象长度为0但仍包含Info的数组

时间:2013-09-04 01:25:46

标签: java

下面我粘贴了一些我一直在研究的代码。我需要从混音器中获取目标线,但我无法弄清楚如何使用Line.Info []数组请求一个。它的长度为0,但如果我将其作为字符串输出,它将保存一行信息。我想投它,但我不知道如何正确地做到这一点。

谢谢, 帽子

 package soundconnect;


    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.Line;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.Mixer;

    public class SoundConnect {

    /**
     * @param args the command line arguments
     */   
    public static void main(String[] args) throws LineUnavailableException {

        Mixer.Info [] Mixes = AudioSystem.getMixerInfo(); 
        Mixer Sys_Mix = AudioSystem.getMixer(Mixes[1]);
        Line.Info[] T_NFO = Sys_Mix.getTargetLineInfo();

        Line Line1 = Sys_Mix.getLine(T_NFO[0]);      


        /* T_NFO has a length of 0 but has some information when I output it 
         * 
         */                
    }
}

1 个答案:

答案 0 :(得分:1)

当您将其作为字符串输出时,表示您正在调用toString()的{​​{1}}方法,该方法是Java中的对象。这将打印出阵列的内存地址和类名。数组对象的默认toString()打印与数组中的元素没有任何关系。它将打印相同的值,无论其中存储的是什么,包括它是否有array长度。

相关问题