The Artima Developer Community
Sponsored Link

Java Answers Forum
Type mismatch error.

1 reply on 1 page. Most recent reply: Jun 18, 2006 12:05 AM by Dave Hinton

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Max Ruben

Posts: 1
Nickname: alex115
Registered: Jun, 2006

Type mismatch error. Posted: Jun 17, 2006 2:06 AM
Reply to this message Reply
Advertisement
I have two classes a Product class and a Product Group class. In the product class a create an accessor method.

private productPrice
public void setProductPrice(double productPrice) {
		this.productPrice = productPrice;
	}


In the productGroup class (I am getting data from a db) I do the following:

Product currentProduct;
while (rs.next()) {
  currentProduct = new Product();
  double productPrice = currentProduct.setProductPrice(rs.getDouble("productPrice"));
    //Add the Product Object to a List
}
 


the javac compiler is throwing the following error: ProductGroup.java:65: setProductPrice(java.lang.String) in Components.Product ca
nnot be applied to (double)
currentProduct.setProductPrice(rs.getDouble("pro
ductPrice"));

I don't understand why it is saying that setProductPrice takes a java.lang. String type when I am coding it to take a variable of type double. Thanks for any answers.


Dave Hinton

Posts: 42
Nickname: catbells
Registered: Oct, 2003

Re: Type mismatch error. Posted: Jun 18, 2006 12:05 AM
Reply to this message Reply
setProductPrice returns void, so you can’t assign it to productPrice.

If that’s the only thing that’s wrong, it’s a very misleading error message.

Flat View: This topic has 1 reply on 1 page
Topic: how to build my own java package Previous Topic   Next Topic Topic: Problem consuming document-style webservice

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use