All Questions
10
questions
0
votes
1
answer
46
views
Why does the visibility of m method change the output in this way? I expected the opposite to occur [duplicate]
Title edit: "my* method" So the root of the problem is the method pmA3. It is present both in class A and in class B. Method lookup would suggest that when pmA3 gets called, it would look for the ...
3
votes
3
answers
69
views
Method nonvisibility of same instanceof but differing class
I have something like the below:
Item var;
Depending on user input, it will be initialized as a different class:
if (/*user input*/ == 1) {
var = new Item();
} else {
var = new Truck();
}
...
5
votes
1
answer
5k
views
Not able to acess package private methods in junit test class
So right now I have the following standard package name setup in my project:
src/main/java/model/SampleClass.java
which you can view @ https://github.com/quinnliu/WalnutiQ/blob/master/src/main/java/...
-4
votes
1
answer
5k
views
The final local variable "name" cannot be assigned, since it is defined in an enclosing type
I have this class:
class Tester{
final String rigaFile=riga;
final BufferedReader r=new BufferedReader(reader2);
fr.getList().addListSelectionListener(new ListSelectionListener() {
...
2
votes
3
answers
102
views
Sub-Protected Method in java. (Can't think of a better way to phrase this) [duplicate]
How could I create a method in a given class that can only be called internally by it, and its subclasses.
For example, the class Foo:
public class Foo{
public Foo(){
}
???? void bar(){
...
0
votes
3
answers
100
views
Java class design issue
Here is a class design: http://pastebin.com/1RSdmtXi
If i put only A to class Expect I would like to see only A's getters and setters, or vica vera to B. If put in A and B, then all of getters and ...
1
vote
1
answer
2k
views
Make the methods of a library not visible for external access but visible for the library
I developed a library and I need that the users of that library can access only to one class ( with a few methods).
For other side I need that this class can access to all library's methods-classes.
...
51
votes
9
answers
24k
views
public methods in package-private classes
Does it make a difference to mark methods as public in package-private classes?
class SomePackagePrivateClass
{
void foo(); // package private method
public void bar(); // public ...
0
votes
5
answers
160
views
Can fields of the class and arguments of the method interfere?
I have a class with a fields called "a". In the class I have a method and in the list of arguments of this method I also have "a". So, which "a" I will see inside of the method? Will it be the field ...
3
votes
7
answers
9k
views
Is there a way to declare a method "friendly" in Java?
I know that attributes can be set public, friendly or private to specify its visibility.
Is there a way I can declare a friendly method? I want it to be accessible only from objects of classes of the ...