I am getting main.java: error: someId in someStruct is defined in an inaccessible class or interface
but how can I solve this?
my main class:
import subdir.Subclass;
public class main{
...
Subclass.someArrayList.get(i).someString
...
}
my subdir.Subclass class:
package subdir;
public class Subclass{
public static java.util.ArrayList<someStruct> someArrayList = new java.util.ArrayList<someStruct>(java.util.Arrays.asList(
new someStruct(3, "string", "string"),
new someStruct(4, "string", "string")
));
}
class someStruct
{
public int someId;
public String someString;
public String someString2;
public someStruct(int someId, String someString, String someString2) {
this.someId = someId;
this.someString = someString;
this.someString2 = someString2;
}
}
If you want to access something from a different package, it must be public
.
You will not be able to access anything that is protected
or private
in another package. They must be public
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With