public class arithmcalc {
public static void main(String[] args) {
int operand1;
int operand2;
char operator;
Scanner sc = new Scanner(System.in);
System.out.println("enter operan1 operand2 and operator one by one");
operand1 = sc.nextInt();
sc.nextLine();
operand2 = sc.nextInt();
sc.next();
operator = sc.findInLine(".").charAt(0);
int result = 0;
switch (operator) {
case '+':
result = operand1 + operand2;
break;
case '-':
result = operand1 - operand2;
break;
case '*':
result = operand1 * operand2;
break;
case '/':
result = operand1 / operand2;
default:
System.out.println("illegal operand");
}
}
}
Exception in thread "main" java.lang.NullPointerException
at javaapplication67.arithmcalc.main(arithmcalc.java:24)