Effective Java: Avoid Strings When Other Types Are More Appropriate

Kyle Carter
1 min readApr 27, 2021

Often when receiving data from files, HTTP requests, keyboard input, etc. we receive that data as a String. Often we just keep these variables as a String even if a different variable type is more appropriate. The most appropriate type depends on what we are trying to represent; if we are trying to represent a finite set of items we may use a enum, true/false means boolean, numbers could be an int, long, or even BigInteger. The benefits of using the appropriate type are as follows:

  • Performance improvements with not…

--

--

Kyle Carter

I'm a software architect that has a passion for software design and sharing with those around me.