The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Justin Johns wrote:It's natural for an Java program to have classes,packages etc.Also it's definite that there are access defined for each of these(class,package).
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Justin Johns wrote:Does that mean you could access an variable in a class from another class provided both classes are in the same package?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Justin Johns wrote:@Winston Gutkowski:Now I got what you mentioned.
Should I now resolve this answer? ... Should I post the code before resolving it?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
…because the Java® Language Specification has already defined its access. It is equivalent to public everywhere.Winston Gutkowski wrote: . . .
A package is simply a place where you put classes - you can't define an "access" for it . . .
Justin Johns wrote:So finally I got how we could access an variable in another class without creating an object provided both classes rest in the same directory.Just make the variable static.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Justin Johns wrote:So finally I got how we could access an variable in another class without creating an object provided both classes rest in the same directory...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
And it is probably best to make it immutable (if it is a reference type), too.Winston Gutkowski wrote: . . . if you define any static field that is not private: always, always always make it final. . . .
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|