I am trying to get this program to count the number of characters in a string. By number of characters l mean not punctuation or a space.What is wrong with my code because l don't understand why the program won't work?
import javax.swing.*;
publiemc class ExamPractise
{
public static void main (String [] geek)
{
String sentence = JOptionPane.showInputDialog("Enter a any sentence");
int countCharacters=0;
for (int i = 0; i < sentence.length(); i++)
{
char c = sentence.charAt(i);
if (c !=' '||c!='?'||c!='.'||c!=' ')
{
countCharacters++;
}
}
System.out.println("There are" + " " + countCharacters + " " + "word");
}
}