• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't find initialized object

 
Colin Gebler
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does your Rechner class have a method called "rechneAus" that takes 6 ints as parameters?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48374
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote: . . . You can copy from cmd. A quick Google search should tell you how.
And so will our FAQ.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ah ,thank you.You were a great help to me
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic