for(int i=0;i<n;i++){
for(int j=0;j<26;j++){
if(str.charAt(i)== strChar.charAt(j) )
* strSet1.append(str.charAt(i));
}
* strSet2.append(str.charAt(i));
}
Exception:
Exception in thread "main" java.lang.NullPointerException
at AterSeries.main(AterSeries.java:33)
why this code gives null pointer exception
warning: Null pointer access: The variable strSet1 can only be null at this location Null pointer access: The variable strSet2 can only be null at this location
str
string is less than either n or 26 – FelkerIndexOutOfBoundsException
.NPE
is thrown when you call a method on a null object for instance. – Beaujolais