Is it a better practice to use Reference types or primitive types in Java? -


this question has answer here:

is considered better practice use , manipulate reference types instead of primitive types in java ?

we see java programs mixing both of them, better use primitive types or reference types ? or mix them according needs , criteria choose between primitive or reference type ?

thanks

assuming mean primitive wrapper types (integer, boolean, etc.) , not reference types in general: when have choice (often don't: e.g. using api requires 1 or other, or use them generic type arguments, or want nullable), prefer primitive types, because on whole make code simpler , faster.

be careful if need switch 1 another, because == still compile give different results... usually.


Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -