java - How to see methods from other class -
i got class made multiple methods, want put of them in class, since other things. how can have first class still use methods?
class a
had 15 private static methods
(they static since return values , don't need define object)
i created class b
in same package , when moving 5 methods in it, main function a
not detect them when used.
your problem visibility. private
means wrapping class can see these methods.
set visibility default (if both classes in same package) or public
if they're in different packages.
for example, classes , b in same package:
// a.java public class { static void onemethod(); } // b.java public class b { private static void anothermethod() { a.onemethod(); } }
or in different packages:
// a.java public class { public static void onemethod(); } // b.java public class b { private static void anothermethod() { a.onemethod(); } }
Comments
Post a Comment