有研究 煤层气 的朋友吗?# Engineering - 工程
o*i
1 楼
【 以下文字转载自 Programming 讨论区 】
发信人: ouyadi (可乐会捂帮帮众), 信区: Programming
标 题: Java代码,老是compile出错,大家帮我看看哪错了。。。
发信站: BBS 未名空间站 (Wed Apr 27 16:58:23 2011, 美东)
我在git上push到学校的服务器后编译老是不通过,错误如下,麻烦大家帮我查下原因
,谢谢啦!
javac -classpath /usr/share/junit/lib/junit.jar -d classes -sourcepath .
Iterator.java List.java TestUpTree.java UpTree.java
UpTree.java:34: type Iterator does not take parameters
public class NIterator implements Iterator{
^
UpTree.java:104: type Iterator does not take parameters
public class SetIterator implements Iterator{
^
TestUpTree.java:51: type Iterator does not take parameters
Iterator it = up.mkIterator();
^
TestUpTree.java:67: type Iterator does not take parameters
Iterator it;
我的Code 如下,其中的Iterator类,我使用了老师提供的接口:
interface Iterator {
UpTree.Node get();
void next();
boolean isValid();
}
public class UpTree {
public List l ;
public int size;
public class Node{
public String data;
public Node up;
private int size;
public Node(String i){
data = i;
up = null;
size = 1;
}
public int size(){
if(this.up==null)
return size;
else
return 0;
}
}
public UpTree(){
l = new List();
size = 0;
}
public Node add(String i){
Node n = new Node(i);
l.insertAtFront(n);
size++;
return n;
}
public class NIterator implements Iterator{
int counter;
public NIterator(){
counter = 1;
}
public UpTree.Node get(){
if(isValid())
return l.get(counter).data;
else
return null;
}
public void next(){
counter++;
}
public boolean isValid(){
if(counter<=l.size())
return true;
else
return false;
}
}
NIterator mkIterator(){
return new NIterator();
}
public void union(UpTree.Node x, UpTree.Node y){
if(x.size != 0){
x.up = y;
if(y.up==null){
y.size = y.size+x.size;
x.size = 0;
}
else{
Node z = find(y);
z.size = z.size+x.size;
x.size = 0;
}
}
else{
Node z = find(x);
z.up = y;
if(y.up==null){
y.size = y.size+z.size;
z.size = 0;
}
else{
Node a = find(y);
a.size = a.size+z.size;
z.size = 0;
}
}
}
public UpTree.Node find(UpTree.Node y){
if(y.up != null){
return find(y.up);
}
else{
return y;
}
}
public int size(){
return size;
}
public class SetIterator implements Iterator{
int counter;
List sl;
public SetIterator(UpTree.Node x){
sl= new List();
sl.insertAtEnd(find(x));
int count = 1;
int counter = 1;
while(count if(find(x).equals(find(l.get(counter).data))){
sl.insertAtFront(l.get(counter).data);
count++;
}
else
counter++;
}
}
public UpTree.Node get(){
return sl.get(counter).data;
}
public void next(){
counter++;
}
public boolean isValid(){
if(counter<=l.size())
return true;
else
return false;
}
}
SetIterator mkSetIterator(Node x){
return new SetIterator(x);
}
}
发信人: ouyadi (可乐会捂帮帮众), 信区: Programming
标 题: Java代码,老是compile出错,大家帮我看看哪错了。。。
发信站: BBS 未名空间站 (Wed Apr 27 16:58:23 2011, 美东)
我在git上push到学校的服务器后编译老是不通过,错误如下,麻烦大家帮我查下原因
,谢谢啦!
javac -classpath /usr/share/junit/lib/junit.jar -d classes -sourcepath .
Iterator.java List.java TestUpTree.java UpTree.java
UpTree.java:34: type Iterator does not take parameters
public class NIterator
^
UpTree.java:104: type Iterator does not take parameters
public class SetIterator
^
TestUpTree.java:51: type Iterator does not take parameters
Iterator
^
TestUpTree.java:67: type Iterator does not take parameters
Iterator
我的Code 如下,其中的Iterator类,我使用了老师提供的接口:
interface Iterator
UpTree.Node get();
void next();
boolean isValid();
}
public class UpTree {
public List
public int size;
public class Node{
public String data;
public Node up;
private int size;
public Node(String i){
data = i;
up = null;
size = 1;
}
public int size(){
if(this.up==null)
return size;
else
return 0;
}
}
public UpTree(){
l = new List
size = 0;
}
public Node add(String i){
Node n = new Node(i);
l.insertAtFront(n);
size++;
return n;
}
public class NIterator
int counter;
public NIterator(){
counter = 1;
}
public UpTree.Node get(){
if(isValid())
return l.get(counter).data;
else
return null;
}
public void next(){
counter++;
}
public boolean isValid(){
if(counter<=l.size())
return true;
else
return false;
}
}
NIterator
return new NIterator
}
public void union(UpTree.Node x, UpTree.Node y){
if(x.size != 0){
x.up = y;
if(y.up==null){
y.size = y.size+x.size;
x.size = 0;
}
else{
Node z = find(y);
z.size = z.size+x.size;
x.size = 0;
}
}
else{
Node z = find(x);
z.up = y;
if(y.up==null){
y.size = y.size+z.size;
z.size = 0;
}
else{
Node a = find(y);
a.size = a.size+z.size;
z.size = 0;
}
}
}
public UpTree.Node find(UpTree.Node y){
if(y.up != null){
return find(y.up);
}
else{
return y;
}
}
public int size(){
return size;
}
public class SetIterator
int counter;
List
public SetIterator(UpTree.Node x){
sl= new List
sl.insertAtEnd(find(x));
int count = 1;
int counter = 1;
while(count
sl.insertAtFront(l.get(counter).data);
count++;
}
else
counter++;
}
}
public UpTree.Node get(){
return sl.get(counter).data;
}
public void next(){
counter++;
}
public boolean isValid(){
if(counter<=l.size())
return true;
else
return false;
}
}
SetIterator
return new SetIterator
}
}