Hello I am a little confused. I had always thought that a class can have objects from other clases as attributes. My teacher recently told me that this is not true... so I am confused now: if one of the attributes of my class is a String, would that be an object inside my class???? Teacher says it's simply a variable...
G_S 38 Junior Poster in Training
Recommended Answers
Jump to Postthe class itself is not a member of that other class, but an instance of it is.
not entirely sure what your question is, or what your teacher said, but sure, if you create a class
MyClassA, you can have another class with a MyClassA as either instance or static …
Jump to PostI don't understand what point your teacher is trying to make.
The Java Language Spec doesn't use the term "attribute" except in two places. One is a very technical discussion of garbage collection, and the other uses it to mean a variable that can be accessed via get/set methods. So …
Jump to Postif one of the attributes of my class is a String, would that be an object inside my class???? Teacher says it's simply a variable...
There is no String inside your object. Keeping aside primitives for the time being, if a class is composed of multiple fields having …
Jump to Postthe same teacher today said that a main method doesn't require a void return type, or any return type at all
Oh man, you really have a problem there; I hope he's not marking your homework. Anyway, you've discovered DaniWeb, where we may not always be right, but …
All 13 Replies
stultuske 1,116 Posting Maven Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
bguild 163 Posting Whiz
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
G_S 38 Junior Poster in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tux4life 2,072 Postaholic
G_S 38 Junior Poster in Training
stultuske 1,116 Posting Maven Featured Poster
tux4life commented: You make a good point about "A main method" versus "THE main method(s)". +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tux4life commented: Yaay, JLS! :) +13
G_S 38 Junior Poster in Training
stultuske 1,116 Posting Maven Featured Poster
G_S 38 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.