CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #2
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Cannot find symbol : class

    First of all, you should post the actual code you're working on. Trying to compile what you posted, I get the following:
    Code:
    AddFractions.java:17: incompatible types
    found   : int
    required: boolean
                if(i = 1)
                     ^
    AddFractions.java:19: non-static variable rTotal cannot be referenced from a static context
                    System.out.println(rTotal + " + " + rToAdd + " = " + rTotal.add(rToAdd));
                                       ^
    AddFractions.java:19: non-static variable rTotal cannot be referenced from a static context
                    System.out.println(rTotal + " + " + rToAdd + " = " + rTotal.add(rToAdd));
                                                                         ^
    AddFractions.java:23: non-static variable rTotal cannot be referenced from a static context
                    System.out.println("Adding " + rToAdd + " to the previous sum of " + rTotal + " = " + rTotal.add(rToAdd));
                                                                                         ^
    AddFractions.java:23: non-static variable rTotal cannot be referenced from a static context
                    System.out.println("Adding " + rToAdd + " to the previous sum of " + rTotal + " = " + rTotal.add(rToAdd));
                                                                                                          ^
    Your error is probably a class path issue. Your Rational class isn't on the default classpath the runtime is using. Take a look at this for some guidance.

    Also note that since you never save the result of rTotal.Add() anywhere, the running total you're looking for (I think) will be lost.
    Last edited by ajhampson; July 14th, 2010 at 08:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured