File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Help, please - conversion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help, please - conversion problem" Watch "Help, please - conversion problem" New topic
Author

Help, please - conversion problem

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

I am trying to compare the INTVALUE of a transaction ID in readRequest to a transaction ID in a hashtable and I get the following error:

Incompatible operand types int and Transaction

My problem code is as follows as :

Transaction transaction = new Transaction();
if (readRequest.getTransactionID().intValue() != transaction.get(readRequest.getTransactionID().intValue())){
responseheader.setStatus(Status.fromString("InvalidTransactionID"));
return response;
}

The method of the transaction object that I am using is at the end of the following:

public class Transaction {
static int TransactionId = 0;
static Hashtable Transactions = new Hashtable();
int Id;

// Constructor created to create & increment the TransactionID's and put
// into Transactions Hashtable.
public Transaction(){
this.Id = TransactionId++;
Transactions.put(new Integer(TransactionId), this);
}

// Method created to grab the TransactionId from the constructor.
public int GetId(){
return Id;
}

// Method created to GET transaction key from the Transactions hashtable.
public static Transaction get(int key){
return get(new Integer(key));
}
}

Any help or direction would be appreciated. Regards.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

if (readRequest.getTransactionID().intValue() != transaction.get(readRequest.getTransactionID().intValue()))


Change the above to:



[My Blog] [JavaRanch Journal]
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Jaikiran,

Thanks so much for your help. It is appreciated.

May I ask this question. Once I did what you suggested I got not an error but a warning stating the following:

The static method get(Object) from the type Transaction should be accessed in a static way

Is this something I need to worry about?

Thanks, again..
[ July 26, 2005: Message edited by: Melinda Savoy ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
Just that instead of:



you should write:



because the get method is static, and doesn't need an object to access it.


Ping & DNS - my free Android networking tools app
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Thanks so much for the help.

Regards.

Originally posted by Ulf Dittmer:
Just that instead of:



you should write:



because the get method is static, and doesn't need an object to access it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help, please - conversion problem