Java 使用数组或任何其他方法初始化JTextArea动态名称

Java 使用数组或任何其他方法初始化JTextArea动态名称,java,swing,jtextarea,Java,Swing,Jtextarea,请给出解决方案。我想使用它的动态名称 for(i=0;i<10;i++) { JTextArea ta[i]= new JTextArea(); String s=""+i; ta[i].setText(s); i++; } for(i=0;i我想你想做的是: // Create an array of JTextArea JTextArea[] jTextAreas = new JTextArea[10]; // Iterate on all the p

请给出解决方案。我想使用它的动态名称

for(i=0;i<10;i++)
{
    JTextArea ta[i]= new JTextArea();
    String s=""+i;
    ta[i].setText(s);
    i++;
}

for(i=0;i我想你想做的是:

// Create an array of JTextArea
JTextArea[] jTextAreas = new JTextArea[10];
// Iterate on all the possible indexes
for(int i=0;i<jTextAreas.length;i++) {
    // Create a new instance of JTextArea for the current index
    jTextAreas[i] = new JTextArea();
    // Set dynamically the text
    jTextAreas[i].setText(Integer.toString(i));
}
//创建JTextArea的数组
JTextArea[]jTextAreas=新的JTextArea[10];
//迭代所有可能的索引

对于(int i=0;i)你的问题是什么?