Hello All
I have an issue.
created 2 java programs, a.java and b.java
content of a.java:
package test;
import test1.*;
publuc class ATEST {
public static void main (String[] args) {
BTEST.call();
}
}
content of b.java:
package test1;
public class BTEST {
string name;
void call() {
.
.
.
}
}
Getting call() is not public in BTEST; cannot be accessed by outside package
Question is b.java must be declared in this fashion. I need to add access modifiers so that call() and any constructors are the only things that are accessible from other packages. Any other method can only be accessed from the BTEST class.
Your kind assistance would be greatly appreciated.
Thanks,
The Ozman
ozman26
0
Newbie Poster
Recommended Answers
Jump to Postno matter what, unless that method is static, you shouldn't call it like this:
BTEST.call();
use public and private access modifiers.
Jump to Postby adding them in the code.
Jump to Postan example based on it? all you need to do is add 'public' in the correct place.
read your textbook or your course notes, it should be all in there.
All 10 Replies
stultuske
1,116
Posting Maven
Featured Poster
ozman26
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
ozman26
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
ozman26
0
Newbie Poster
ozman26
0
Newbie Poster
xPro
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
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.