• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

setters-getters 3 classes

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is a basic question but I really struggle with this

First class:



Second Class:


Third class:



RESULT: 0

I know I make a new object in class A thats why the sysout returns 0. How can I make it so that I GET the value 2 instead of null in class A, and that I'm able to SET things in class B. So I stay at the same object so to say.

I just want to be able to SET things in class B and GET that same value from the setter-getter-class-C, in class A. Please help

Thanks in advance, Jimme
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Based on the code you posted, class A should not compile.

Henry
 
Marshal
Posts: 70251
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Henry Wong wrote:. . . class A should not compile.  . . .

The solution is to create an instance method which you can refer to b from.
 
    Bookmark Topic Watch Topic
  • New Topic