Skip to content

Instantly share code, notes, and snippets.

@anthonyjdella
Created April 18, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyjdella/553f543223010e0b073b63caf92f297d to your computer and use it in GitHub Desktop.
Save anthonyjdella/553f543223010e0b073b63caf92f297d to your computer and use it in GitHub Desktop.
Java without Magic Numbers
class MagicNumber {
String pipeDelimitedString = "This|is|an|example|of|Magic|Numbers|123 Parker Road|cityline@gmail.com";
String [] splitString = pipeDelimitedString.split("\\|");
obj.doSomething(splitString[Constants.HOME_ADDRESS]);
obj.doSomething(splitString[Constants.EMAIL_ADDRESS]);
}
class Constants {
public static final int HOME_ADDRESS = 7;
public static final int EMAIL_ADDRESS = 8;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment