开发者

Java error cannot find symbol class Scanner.using jdk 6

开发者 https://www.devze.com 2023-01-17 10:00 出处:网络
import java.util.scanner; import javax.swing.JOptionPane; public class FirstHomeJavaApplet{ public static void main(String[] args){
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).

0

精彩评论

暂无评论...
验证码 换一张
取 消