public static int readConvert(char[]post)throws IOException{
Stack S = new Stack();
int j=0;
char c;
System.out.printf("Type an infix expression and press Enter\n");
char token =getToken();
while (token!='\0'){
if (Character.isDigit(token))post [j++]=token;
else if (token =='(')S.push(new NodeData('('));
else if (token ==')')
while ((c=S.pop().getData())!='(')post[j++]=c;
else {
while (!S.empty() && precedence(S.peek().getData())>= precedence(token))
post[j++]=S.pop().getData();
S.push(new NodeData(token));
}
token=getToken();
}
while (!S.empty())post[j++]=S.pop().getData();
return j;
}
问题:(1)为什么eclipse告诉我,我的getData()未定义为类型对象。
我创建的课程:
public class Node{
public NodeData data;
NodeData next;
public Node(Nodedata d){
data = d;
next = null;
}
public class NodeData{
char ch;
public NodeData(char c){
ch =c;
}
public char getData() {return ch;}
public int compareTo(NodeData nd){
if (this.ch ==nd.ch)return 0;
if (this.ch<nd.ch) return -1;
return 1;
}
public String toString(){
return ch + " "; //" " needed to convert num to a string
}
}
}
问题:(2)为什么当我尝试编译eclipse时表明NodeData无法解析为某种类型。
答案 0 :(得分:0)
SELECT f.*, p.*,
COALESCE(p.img, 'profile_images/default.jpg') as profile_img
FROM friends f LEFT JOIN
profile_img p
ON p.user_id = f.friend_one AND
p.id = (select max(p2.id) from profile_img p2 where p2.user_id = p.user_id)
WHERE f.friend_two = ? AND f.status = ?;
方法返回pop
中使用的类类型,因此请尝试栈&LT; NODEDATA&GT; stack = new Stack&lt; NodeData&gt;();