[英]Why doesn't println() read my package that I've created?
我寫了一個程序,它可以工作,但不是我希望的那樣。 所以我做了一個包,當我試圖將我的包放入我的print()
語句時,它說找不到符號,但我在頂部導入了它。
這是我到目前為止的代碼:
//Program is is beng made to graph students incorrect entries
import java.util.*;
import java.io.*;
import java.util.Scanner;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.List;
import java.lang.ArrayIndexOutOfBoundsException;
import utils.*;
public class Histo
{
public static void main(String [] args) throws FileNotFoundException
{
Scanner textFile = new Scanner(System.in);
System.out.println("Enter integers that are less than 25, one per line, hit control + z, when finished");
int[]scores = new int[26];
while( textFile.hasNext())
{
int startStar = textFile.nextInt();
scores[startStar]++;
}
for ( int stars = 0; stars < scores.length; stars++)
{
if (scores[stars] != 0)
{
System.out.print( stars + " ");
for ( int n = 1; n <= scores[stars]; n++)
{
System.out.print("*" + TextKit.lineOfStars);
}
System.out.println();
}
}
}
}
我想你指的是https://wpollock.com/AJava/TextKit/TextKit.java指定的類utils.TextKit
它有一個靜態方法lineOfStars
需要一個整數作為參數。
因此,我想您需要這樣做:
....
if (scores[stars] != 0)
{
System.out.print(stars + " ");
System.out.println(TextKit.lineOfStars(scores[stars]));
}
或者更簡單:
....
if (scores[stars] != 0)
System.out.println(stars + " " + TextKit.lineOfStars(scores[stars]));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.