Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a performace impact for those ?

 
Costa lamona
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
continue
break
return

Is there a performance bad effect for those keywords?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each of these are used for different functionalities. I dont see a way how these statements would affect the performance in any way. Any reason why you are trying to figure out the performance impact of these 3 control statements?
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The use of break and continue is frowned upon more because it makes for confusing code than for any performance issues.
You can't avoid using return. Every method has to return some time or another. There is also a rule of thumb that one should not return anywhere but the end of the method because it is difficult to find return statements buried in code and can confuse readers.
 
Paul Clapham
Sheriff
Posts: 21312
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you talk about performance impacts, you must always be comparing two options. You can't say something is "better" without saying what it is better than.

Now, for example, what are you comparing "return" to? Not returning? The other thing you must always consider when comparing the performance of two options is that the two options must be doing the same thing. Otherwise your comparison is worthless.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any real application this would not be a bottleneck, and so you will find most developers won't know much about the performance characteristics of the keywords you mention. Even if there was a difference it likely would be different between VM's, and versions of the jdk.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic