Compiler error - cannot be applied to (int)

J

Jan Danielsson

Hello all,

I get the folloing errors:
--------------------------
PersonalEconomy.java:1374: getTableId() in IdPair cannot be applied to (int)
int id = ip.getTableId(i);
^
PersonalEconomy.java:1375: getTableId() in IdPair cannot be applied to (int)
if(idTable == ip.getTableId(i)) {
^
PersonalEconomy.java:1376: getFileId() in IdPair cannot be applied to (int)
return ip.getFileId(i);
^
PersonalEconomy.java:1384: getFileId() in IdPair cannot be applied to (int)
if(idFile == ip.getFileId(i)) {
^
PersonalEconomy.java:1385: getTableId() in IdPair cannot be applied to (int)
return ip.getTableId(i);
^
5 errors
--------------------------

When I compile this:
--------------------------
class IdPair {
private int idFile; // id in file
private int idTable; // id in table

public IdPair(int idFile, int idTable) {
this.idFile = idFile;
this.idTable = idTable;
}
public int getFileId() {
return idFile;
}
public int getTableId() {
return idTable;
}
}

class IdPairs {
private Vector<IdPair> list = new Vector<IdPair>();

public void add(int idFile, int idTable) {
list.add(new IdPair(idFile, idTable));
}
public int lookupFile(int idTable) {
for(int i = 0; i < list.size(); i++) {
IdPair ip = list.elementAt(i);
int id = ip.getTableId(i);
if(idTable == ip.getTableId(i)) {
return ip.getFileId(i);
}
}
return -1;
}
public int lookupTable(int idFile) {
for(int i = 0; i < list.size(); i++) {
IdPair ip = list.elementAt(i);
if(idFile == ip.getFileId(i)) {
return ip.getTableId(i);
}
}
return -1;
}
}
 
M

Mike Schilling

Jan Danielsson said:
Hello all,

I get the folloing errors:
--------------------------
PersonalEconomy.java:1374: getTableId() in IdPair cannot be applied to
(int)
int id = ip.getTableId(i);
^
PersonalEconomy.java:1375: getTableId() in IdPair cannot be applied to
(int)
if(idTable == ip.getTableId(i)) {
^
PersonalEconomy.java:1376: getFileId() in IdPair cannot be applied to
(int)
return ip.getFileId(i);
^
PersonalEconomy.java:1384: getFileId() in IdPair cannot be applied to
(int)
if(idFile == ip.getFileId(i)) {
^
PersonalEconomy.java:1385: getTableId() in IdPair cannot be applied to
(int)
return ip.getTableId(i);
^
5 errors
--------------------------

When I compile this:
--------------------------
class IdPair {
private int idFile; // id in file
private int idTable; // id in table

public IdPair(int idFile, int idTable) {
this.idFile = idFile;
this.idTable = idTable;
}
public int getFileId() {
return idFile;
}
public int getTableId() {
return idTable;
}
}


What am I doing wrong?

You're calling a method that takes no arguments with one argument.
Try ip.getTableId() and ip.getFileId()
 
J

Jan Danielsson

Mike Schilling wrote:
[---]
You're calling a method that takes no arguments with one argument.
Try ip.getTableId() and ip.getFileId()

I feel like an idiot. Thanks for spotting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,978
Messages
2,570,180
Members
46,716
Latest member
venkatesh

Latest Threads

Top