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 2 of 2

Thread: Behaviour of shortcut assignment and normal assignment for float

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Location
    Kerala
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Behaviour of shortcut assignment and normal assignment for float

    I have a simple doubt
    float k = 0;        
    k+=0.2;     
    k=k+0.2; // here compliation error

    compliation error Type mismatch: cannot convert from double to float

    My question is why not a complilation error at k+=0.2;


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,304
    My Mood
    Mellow
    Thanks
    252
    Thanked 778 Times in 763 Posts

    Default Re: Behaviour of shortcut assignment and normal assignment for float

    You can find most answers to questions like these by searching the net. Searching "java += operator" yielded this article near the top.

Similar Threads

  1. need help with an assignment
    By milham123 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 23rd, 2013, 04:14 PM
  2. Help with assignment
    By kayc1912 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 21st, 2013, 02:02 PM
  3. Assignment
    By millions in forum Java Theory & Questions
    Replies: 1
    Last Post: July 2nd, 2012, 05:15 PM
  4. assignment troubles polymorphism (guide for assignment included)
    By tdawg422 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2011, 11:01 AM
  5. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM

Tags for this Thread