This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Program Error,Thanks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Program Error,Thanks" Watch "Program Error,Thanks" New topic

Program Error,Thanks

Jiali Yang

Joined: Mar 20, 2006
Posts: 3
public class MultiplyNumbers{
public static void main(String[] args)
String s1;
String s2;
Double num1,num2,product;

InputStreamReader isr=new InputStreamReader(;
BufferedReader br=new BufferedReader(isr);

System.out.println("Enter a number: ");

System.out.println("Great! Now enter another number: ");

System.out.println(num1+" times "+num2+" is "+product);

以下是错误提示: incompatible types
found : double
required: java.lang.Double
^ incompatible types
found : double
required: java.lang.Double
^ operator * cannot be applied to java.lang.Double,java.lang.Double
3 errors

<a href="" target="_blank" rel="nofollow"></a>
marc weber

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

My guess is that you want num1, num2, and product to be of type double (with a lowercase 'd') instead of type Double (with an uppercase 'D').

(The uppercase Double is a wrapper class.)

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Double.parseDouble() method returns primitive data type double and not Double.
So declare num1,num2,product as double instead of Double as:

double num1,num2,product;;
Jiali Yang

Joined: Mar 20, 2006
Posts: 3
Thank you for your help!
I find JavaRanch yesterday,and I like the website very much.
I'm from China,so my English is poor,but I will work hard to find useful message here.

I agree. Here's the link:
subject: Program Error,Thanks
Similar Threads
program assignment help
inpteractive input with println and!
Test Input Calculator Help
"Double" and "double" - what's the difference?
eek, help!