由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Java代码,老是compile出错,大家帮我看看哪错了。。。
相关主题
Why java.lang.Iterable depends on java.util.Iteratorcan applet implements runnable?
Re: connection pool问一个特别土的问题
请教大家:如何modify java code in order to compileTimer and TimerTask
how do I get parameters passed by text area (form要随机返回一个Set的里的元素, 如何操作呢?
A design for parameter passingjvm是怎么implement monitor的?
synchronized method does lock the object that passed into the method as a parameter?synchronization for counters
invoke a function dynamically in Java?问一道关于Vector的题
jdbc connection timeout ?interface和implementation class
相关话题的讨论汇总
话题: node话题: public话题: iterator话题: counter话题: return
进入Java版参与讨论
1 (共1页)
o****i
发帖数: 1706
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);
}
}
d**k
发帖数: 1223
2
compiler 版本不对吧? 不太sure
r*****l
发帖数: 2859
3
At least this looks not normal: l = new List();

【在 o****i 的大作中提到】
: 【 以下文字转载自 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{

F****n
发帖数: 3271
4
Remove your generic parameter. It is unnecessary, confusing and probably incorrectly specified.

【在 o****i 的大作中提到】
: 【 以下文字转载自 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{

1 (共1页)
进入Java版参与讨论
相关主题
interface和implementation classA design for parameter passing
看了下storm,大概明白了怎么做real time系统了synchronized method does lock the object that passed into the method as a parameter?
HashMap 怎样循环用更快?invoke a function dynamically in Java?
这道题该走什么路jdbc connection timeout ?
Why java.lang.Iterable depends on java.util.Iteratorcan applet implements runnable?
Re: connection pool问一个特别土的问题
请教大家:如何modify java code in order to compileTimer and TimerTask
how do I get parameters passed by text area (form要随机返回一个Set的里的元素, 如何操作呢?
相关话题的讨论汇总
话题: node话题: public话题: iterator话题: counter话题: return