Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Double.parseDouble possible issue  RSS feed

 
Mike Rothgeb
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing this for a class assignment. I have run the code in both NetBeans and command prompt and it works just fine. However, in jGrasp, which is what I am to use it does not compile. Here is the code and the error that I continually get is located at the bottom. It is telling me that it cannot find the "." symbol. Am I missing something here? I have done all I can think of thus far. Any suggestions would be great. Thanks!
Errors
 
Liutauras Vilda
Marshal
Posts: 4636
316
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Mike.

I can't see nothing wrong with this code, it runs just fine for me. One thing I can think of is, maybe you didn't save latest version of your code and running the previous one.
Even IDE's requires you to save code manually before you run it. Sorry, don't know any other possible reason.

By the way, I added code tags for you. When you post code, always use them, it makes your code way more readable.
 
Mike Rothgeb
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Mike!

I was thinking I would delete the file and create a new one to see if that might solve the problem.
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also check if you have your own class named Double. I created a Double class and get this error:
 
Campbell Ritchie
Marshal
Posts: 55687
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder has got the likeliest solution. When the javac tool searches for a class, it goes in this order:-
  • 1: current package
  • 2: java.lang package
  • 3: Anything named in import statements. Beware if you have two jars containing classes with the same name; you cannot tell which the javac tool will find.
  • If you have created your own Double class in the same package, that is what javac is finding.

    Principle: Never create classes with the same simple name as classes in the java.lang package. Never create classes with the same simple name as what you are importing.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!