[英]Facing error while creating an array of object referances in java
public class HashChaining {……公共类哈希链{……
class HashTable
{
int tsize; LLNode Table[];
};
public static void main(String []args)
{
HashChaining eg;
HashChaining.HashTable h;
h=eg.new HashTable();
h.Table=eg.new LLNode[11];
……….. } } ……….. } }
getting error while compiling: HashChaining.java:85: error: '(' expected h.Table=eg.new LLNode[11]; ^ 1 error编译时出错:HashChaining.java:85: error: '(' expected h.Table=eg.new LLNode[11]; ^ 1 error
This is the way I would do it and does not give any compilation error.这是我会这样做的方式,并且不会给出任何编译错误。
public class HashChaining {
class HashTable {
int tsize;
LLNode Table[];
}
class LLNode {
int key;
Student value = new Student();
LLNode next;
}
class Student {
String name;
String branch;
}
public static void main(String[] args) {
HashChaining eg = new HashChaining();
HashChaining.HashTable h = eg.new HashTable();
h.Table = new LLNode[11];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.