If You check System.out.print(names.length);
you will get 3 i.e. names length is 3. your loop is running from 0 to 3 which should be running either 0 to 2 or 1 to 3
Solution
String[] name = {"Ram", "Raj", "Hari"};
for(int i = 0; i<names.length; i++) {
System.out.print(names[i] +'\n');
}