I have a class called Person that looks something like this:
public abstract class Person {
private String birthNo;
...
}
Numbers of Norwegian births are 11 digits and are constructed according to the algorithm described on this page on Wikipedia . I cannot use int since most birth numbers are greater than Integer.MAX_VALUE.
I heard that when deciding whether to use a String or integer to store numeric values, you should ask yourself: do I need to perform mathematical operations on this value?
I do this on birthNo, but many operations become somewhat easier with String charAt(int i). If I were to keep birth numbers for how long, I would have to use modulo and division to get the desired digit:
int ninth = Character.getNumericValue(birthNo.charAt(8));
against.
int ninth = birthNo / 100 % 10
, , - (, 9- ) , ISBN.
String , , , "11 ", .
? ?