• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why can't I refer to setLenght frm this class?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I try to get the following code to work. I made a class(Rechthoek) with a constructor and getters and setters.

Now, I am trying to make a second class which should create several "rechthoek" objects (setting values in the code of the Rechhoekapplicatie class -->which also acts as main class). However I can't seem set the values in the code; the setter methods won't do it.

I treid: Rechthoek.setLengte() but for some reason the program tells me I need a method setLengte, but I already have a settermethod (setLengte) for it! I do not get it! Can anyone tell me where I am going wrong in the following code?

(Edit: to shed some light on the names used --> rechthoek = retangle lengte=lenght and breedte=width.)

Class1:


Class 2:


So...can anyone please shove me into the right direction??
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dirk Lucas wrote:
So...can anyone please shove me into the right direction??




From a very quick look, here are two issues...

1. The setLenght() method is an instance method. You actually need an instance to be able to call it. Only static methods can be called with just the class name to qualify it.

2. The signature of the method must match. You actually don't have a setLenght() method that takes no parameters.

Henry
 
Dirk Lucas
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah! Thanks I got it!

There was more wrong than just that, but I think my question might not have been the clearest either;)

I thank you for your reply!

Kr.
 
reply
    Bookmark Topic Watch Topic
  • New Topic