• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

cannot find symbol method store string error code

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the following code in my controller class and i get the aforementioned error code wherever the repository.store method is called

this happens even though i have the following method in my repository
 
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the whole of the error code and show which line it refers to
 
Saloon Keeper
Posts: 14267
321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also show where you declared repository.
 
Georgios Adamidis
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the whole error code is "Cannot find symbol Symbol:method store (String location: variable repository of type Object)" it appears in lines 11,18,23,28 i have imported the repository in the following bit of code
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless you hve created your own Object class (a bad idea), the Object class doesn't have a store() method. Yui will have to declare it with the correct type.
 
Georgios Adamidis
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Unless you hve created your own Object class (a bad idea), the Object class doesn't have a store() method. Yui will have to declare it with the correct type.



What is the correct type?
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. This is your code; you are writing the classes. That is something you should know.
 
Georgios Adamidis
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Don't know. This is your code; you are writing the classes. That is something you should know.


I have a store method in my repository class i just dont known how to import the method from the repository class to the controller class.. hopefully someone can help i have tried
but i get a "package repository does not exist" error code
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class should be called Repository. You can't import instance methods. If you declared repository of type Repository it might work
 
Georgios Adamidis
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:The class should be called Repository. You can't import instance methods. If you declared repository of type Repository it might work


i tried

and

but i get a "Cannot find symbol symbol class store Location Class Repository
 
Stephan van Hulst
Saloon Keeper
Posts: 14267
321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to declare the variable as the type that contains that method. Then you need to assign an instance of that type.

If you don't know how to do any of that, I suggest you read through the Java tutorials.
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Georgios Adamidis
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the aforementioned error code on line 15. my code is as follows.. any help is much appreciated
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please go back to what you were taught at the very first. Please revise the general structure of a class: fields methods and constructors. Why haven't you declared all the fields as private? Why didn't you write a constructor for your class? How does the repository work? How does it match restaurants to their reviews?
 
Campbell Ritchie
Marshal
Posts: 76412
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your questions are all closely related, so I have made a single thre‍ad out of them.

Stephan van Hulst wrote:. . . If you don't know how to do any of that, I suggest you read through the Java tutorials.

A few minutes ago, I wrote:Please go back to what you were taught at the very first. Please revise the general structure of a class . . .

It would appear we both think you have forgotten the basics of writing a class, and I think that correcting that will correct many of your problems.
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic