Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Why the compiler can not find the symbol?

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Why the compiler can not find the symbol?

    I am tryuibg to compile the following using Netbeans.
    public class Example1 {
         public int sumOfDigits(int n)
         {
     
              int sum = 0;
              n = Math.abs(n);
              while (n > 0)
              {
                   sum += n % 10;
                   n /= 10;
              }
              return sum;
         }
         public void inputAndProcess(Input in)
         {
              System.out.print("Type an integer: ");
              int n = in.nextInt();
              System.out.print("The sum of the digits of: " + n);
              System.out.println(" is: " + sumOfDigits(n));
         }
     
         // The main method should do no more than create the object
         // and call a method to do the work.
         public static void main(String[] args)
         {
              new Example1().inputAndProcess(new Input());
     
         }
    }
    The compilation gives me 2 errors (actually the same error twice) :
    Can NOT find Symbol class Input location class Example1

    I am using the latest Java JDK. What should I do? Please help.
    Last edited by helloworld922; February 16th, 2010 at 08:11 PM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Why the compiler can not find the symbol?

    Input isn't a default Java API class. You either need to write it yourself or get it from someone. If you want to just get input from the user, try using a Scanner object:

    public void inputAndProcess(Scanner in)
    {
         // your code above is fine
    }
     
    public static void main(String[] args)
    {
         new Example1().inputAndProcess(new Scanner(System.in);
    }

Similar Threads

  1. cannot find symbol - method
    By kyuss in forum Object Oriented Programming
    Replies: 2
    Last Post: December 7th, 2009, 01:01 PM
  2. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM
  3. sql compiler
    By tsuki in forum JDBC & Databases
    Replies: 6
    Last Post: October 16th, 2009, 10:35 PM
  4. cannot find symbol variable radius?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 4th, 2009, 10:29 AM
  5. Replies: 5
    Last Post: September 19th, 2009, 06:48 AM