aspose file tools*
The moose likes Beginning Java and the fly likes can't find initialized object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can Watch "can New topic
Author

can't find initialized object

Colin Gebler
Greenhorn

Joined: Apr 13, 2013
Posts: 10
So i am writing some Testcode and have to access the Methods of the "real" class to do so.I initialize an instance of the class "Rechner" this way:


This happens in main.After that main calls a Method including this block of code;



Now,if i try to compile it it says :

RechnerTest.java:23: error: cannot find symbol
Test.rechneAus(3,4,0,0,0,0);

Code is copy&pasted ,the error message had to be typed since i am learning on cmd.

Looking forward for some help.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

does your Rechner class have a method called "rechneAus" that takes 6 ints as parameters?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Colin Gebler wrote:So i am writing some Testcode and have to access the Methods of the "real" class to do so.


No idea what you mean by "real" class. By contrast, what would be a "fake" class?


RechnerTest.java:23: error: cannot find symbol
Test.rechneAus(3,4,0,0,0,0);


There's no method called rechneAus that can accept 6 ints as it agruments defined on whatever class Test refers to,

Also note that variables by convention start with lowercase. If you follow that convention, it will be easier for others to understand your code.

Code is copy&pasted ,the error message had to be typed since i am learning on cmd.


You can copy from cmd. A quick Google search should tell you how.
Colin Gebler
Greenhorn

Joined: Apr 13, 2013
Posts: 10
The real class is the one being tested(the one with the methods i want to call) ,thats what i meant

it accepts doubles ,do i have to declare that it is double?



So what would be the correct code to call this method?

and thanks i will keep the convention in mind
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Jeff Verdegan wrote: . . . You can copy from cmd. A quick Google search should tell you how.
And so will our FAQ.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Colin Gebler wrote:The real class is the one being tested(the one with the methods i want to call) ,thats what i meant

it accepts doubles ,do i have to declare that it is double?



If your method accepts doubles, then you can pass ints instead, and they will be automatically promoted. Here are some other things to look at:

  • Spelling and case of the variable name. If you have a similarly named variable or class, then "Test" might not refer to what you think it does.
  • Spelling and case of the method name.
  • Scope of the variable. If the "Test" variable is a local in either or both of the methods where you're creating the object and where you're trying to use Test, you may have two different "Test"s.


  • It would be easier to help you if you could provide an SSCCE(←click) rather than disparate snippets with no context.
    Colin Gebler
    Greenhorn

    Joined: Apr 13, 2013
    Posts: 10
    Ah ,thank you.You were a great help to me
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: can't find initialized object