我在包序列中有一个 Logistic 类
package sequence;
class LogisticSeq {
int limit;
double lamda;
ArrayList <Double> lseq = new ArrayList <Double>();
LogisticSeq(int a, double b, double c) {
limit = a;
lseq.add(b);
lamda = c; }
void sequence() throws IOException{
File file = new File("Sequence.txt");
if (!file.exists()) {
file.createNewFile();
}}
public class Logistic {
public static void main (String[] args) throws IOException {
LogisticSeq L = new LogisticSeq(50,0.4999,3.9999);
L.logisticsequence();
}
如何从其他包中的类访问LogisticSeq类
最佳答案
你说:
@Hovercraft Full Of Eels I tried to change it to public but i got the error in eclipse and says to define it in its own file.
听起来您要么将 LogisticSeq 类放在一个包含多个类的文件中,要么您的类/包名称与项目的包/文件结构不匹配。
我建议您按照 Java 编译器告诉您的去做:在序列包中创建一个 LogisticSeq.java 文件,并确保该类是公共(public)的。
关于java - 从其他包访问非公共(public)类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21218987/