import java.util.scanner;
import javax.swing.JOptionPane;
public class FirstHomeJavaApplet{
public static void main(String[] args){
int num1=2;
int num2=2;
int sum;
sum=num1+num2;
System.out.println("My first home practice of java applet");
JOptionPane.showMessageDialog(null, num1 + "+" + num2 + " = " + sum, "Result of Addition",
JOptionPane.INFORMATION_MESSAGE);
}
}
This is my code but it is giving 1 error.I am using jdk 6 to run this applet.
The error is :cannot find symbol
symbol:class scanner
location:package java.util
import.java.util.scanner;
^
开发者_开发问答Thanks..
Scanner should start with a capital S :)
By convention, Java classes start with capital letters. So it should be Scanner
throughout. E.g.
import java.util.Scanner;
See that your class name starts with a Capital letter java.util.Scanner; instead of java.util.scanner;
Because the class name is Scanner not scanner.
The class is called java.util.Scanner (with a capital S).
精彩评论