• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

better performance between compound assignment operator and casting

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that we don't need to cast explicitly into another data type by using compound assignment operators in some cases. I want to know which way can provide better performance? or their performance levels are same?

For eg,



regarding to line 4 and 5, which line provides better performance?

thanks
 
Saloon Keeper
Posts: 12142
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably the compound assignment, but it REALLY doesn't matter. You need to use the clearest code, which in this case is the compound assignment. The difference in performance is going to mean absolutely nothing compared to other operations that your application has to perform, such as displaying data, networking, accessing databases and files, etc.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And for the OCAJP certification exam it doesn't matter at all! You won't be questioned about which of these statements provides the better performance.
 
get schwifty. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic