I know MongoDB field name is case sensitive, at least while retrieving a value for the field. I have following Java Program.
public class SimpleDocument {
public static void main(String[] args) {
Document doc = new Document("String","Aeroplane").append("int", 20);
String s1 = doc.getString("String");
String s2 = doc.getString("string");
System.out.println("s1="+s1+" and s2="+s2);
int i1 = doc.getInteger("int");
int i2 = doc.getInteger("Int"); //throws NullPointerException
System.out.println("i1="+i1+" and i2="+i2);
}
}
The first Sysout displays output as expected i.e., s1="Aeroplane" and s2=null. But the 2nd Sysout does not display anything as the line just above it throws a NullPointerException which I can't understand.
Can anybody explain the logic?