Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: this.something = something - problem with "double"

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default this.something = something - problem with "double"

    I have a rather simple problem, but I can't solve it somehow.

    class lokomotiva extends element{
     
    	public lokomotiva(double maxMasa){
     
    		super(maxMasa);
     
    		this.maxMasa = maxMasa;
     
    	}
    }

    when i try to compile the whole thing (this is just a part of the code), I get an error:
    possible loss of precision
    found :double
    required: int
    at: this.maxMasa = maxMasa

    maxMasa is a double number, and I want it to be, but how to assign it to an object?

    Any help would be appriciated


  2. #2
    Member
    Join Date
    Feb 2011
    Posts
    55
    My Mood
    Tolerant
    Thanks
    1
    Thanked 16 Times in 15 Posts

    Default Re: this.something = something - problem with "double"

    I'm guessing that maxMasa in the element class is an int, can you verify the type in the element class?

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: this.something = something - problem with "double"

    I don't know how could I have missed that. It works now. Thx m8.

Similar Threads

  1. problem using the "extend"
    By Eildotcom in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 25th, 2010, 06:54 PM
  2. Java says:"Hello World". I say:"It works!"
    By Davidovic in forum Member Introductions
    Replies: 4
    Last Post: June 29th, 2010, 07:13 AM
  3. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM
  4. [SOLVED] Is "Public void closeFile()" a problem in the program for AS-Level computing project
    By muffin in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 5th, 2009, 09:12 PM
  5. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 10:26 AM