gpt4 book ai didi

java - 读取文本文件: Error - Variable out of type FileWriter

转载 作者:行者123 更新时间:2023-12-02 10:59:53 25 4
gpt4 key购买 nike

import java.io.*;
import java.util.*;

class Permutation {
static void combinationUtil(int arr[], int n, int r, FileWriter out, int index,int data[], int i)
{
if (index == r)
{
for (int j=0; j<r; j++)
out.print(data[j]+" ");
out.println(" ");

return;
}


if (i >= n)
return;


data[index] = arr[i];
combinationUtil(arr, n, r, out, index+1, data, i+1);
combinationUtil(arr, n, r, out, index, data, i+1);
}


static void printCombination(int arr[], int n, int r, FileWriter out)
{

int data[]=new int[r];
combinationUtil(arr, n, r,out, 0, data, 0);
}


public static void main (String[] args) {
File file = new File("output.txt");
file.createNewFile();
FileWriter out = new FileWriter(file);
int arr[] = {1, 2, 3, 4, 5, 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28};
int r = 6;
int n = arr.length;
printCombination(arr, n, r, out);
out.flush();
out.close();
}//end main
}//end calss

错误

C:\Users\Student\Documents\Permutation.java:21: error: cannot find symbol out.print(data[j]+" "); ^ symbol: method print(String) location: variable out of type FileWriter 1 error



流程完成。
纠正此错误帮助时遇到问题。我尝试使用单独的函数传递它,但没有用。

最佳答案

outSystem的静态成员,应称为此类System.out.print(data[j]+" ")

关于java - 读取文本文件: Error - Variable out of type FileWriter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45356948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com