The Artima Developer Community
Sponsored Link

Java Answers Forum
Parameters in class are objects from another class

1 reply on 1 page. Most recent reply: Oct 28, 2015 8:48 AM by Sujata Patil

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Michael Rootshtain

Posts: 1
Nickname: mike50710
Registered: Sep, 2015

Parameters in class are objects from another class Posted: Sep 5, 2015 12:50 PM
Reply to this message Reply
Advertisement
If I have a class called Student which consists of a name and a grade as attributes and a separate class called Subject which receives Student as a parameter, how do I access the attributes of the Student in the Subject class


Sujata Patil

Posts: 2
Nickname: jyorat
Registered: Oct, 2015

Re: Parameters in class are objects from another class Posted: Oct 28, 2015 8:48 AM
Reply to this message Reply
Best way is to add getter and setter methods for both the attributes in the student class and access these using get method in the department

Flat View: This topic has 1 reply on 1 page
Topic: draw situation not working in game of tictac toe in java Previous Topic   Next Topic Topic: customize right click context menu of linux file or folder using java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use