I am beginner in Java. As I was going through the book, I got stuck on this problem. My question is why there are single quotes instead of double quotes around this period. When we want to print a string, we use double quotes.

I am beginner in Java. As I was going through the book, I got stuck on this problem. My question is why there are single quotes instead of double quotes around this period. When we want to print a string, we use double quotes.

'.' would indicate a type of char
"." would indicate a type of string
Both will work to print
In Java, we use '' to delimit a char and "" to delimit a String.
In this particular case, you need a char because you are comparing '.' with the result of a call to the charAt method - which is always a char. That is to say, sentence.charAt(lastCharPosition) has to be a char, so it can only be '.' and never ".".
If you wanted a String, (which you don't in this case), you could write ".".