1
명령 줄에 값을 출력하는 재귀 적 메서드가 있습니다. temp 배열을 만들고 Swing을 사용하여 결과를 표시해야합니다. 루프를 만들 때마다 배열을 만들고 값을 저장하는 방법은 무엇입니까?자바에서 재귀 함수로 배열을 만드는 방법
static void listSnapshots(VirtualMachine vm)
{
if(vm == null)
{
JOptionPane.showMessageDialog(null, "Please make sure you selected existing vm");
return;
}
VirtualMachineSnapshotInfo snapInfo = vm.getSnapshot();
VirtualMachineSnapshotTree[] snapTree = snapInfo.getRootSnapshotList();
printSnapshots(snapTree);
}
static void printSnapshots(VirtualMachineSnapshotTree[] snapTree)
{
VirtualMachineSnapshotTree node;
VirtualMachineSnapshotTree[] childTree;
for(int i=0; snapTree!=null && i < snapTree.length; i++)
{
node = snapTree[i];
System.out.println("Snapshot name: " + node.getName());
JOptionPane.showMessageDialog(null, "Snapshot name: " + node.getName());
childTree = node.getChildSnapshotList();
if(childTree != null)
{
printSnapshots(childTree);
}
}//end of for
그래서 JOptionPane 대신 이름 목록이있는 새 창만 있고 나중에 재사용 할 수 있습니다.