aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 386

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: 9317
    
109

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: 386

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: 39547
    
  27
Just that instead of:



you should write:



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


Ping & DNS - updated with new look and Ping home screen widget
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help, please - conversion problem
 
Similar Threads
Question re: nested IF statements
Passing values into the SQL connection class?
Lookup key in HashTable
findByPrimaryKey not being called
Creating new class question