+ 1

How can I access a class from another class of same package?Both classes are defined beginning with package keyword.

I have tried importing the class and calling directly. But that does not work.

11th Jul 2018, 1:09 PM
SRAJAN GUPTA
SRAJAN GUPTA - avatar
4 Respuestas
+ 1
Post the code for a better answer
11th Jul 2018, 3:48 PM
Christopher O'Neill
+ 1
package AHA; public class CLASS1{ public static void main(String args[]) { System.out.println("WELCOME SRAJAN..........."); CLASS2 g=new CLASS2(); } }
11th Jul 2018, 7:11 PM
SRAJAN GUPTA
SRAJAN GUPTA - avatar
+ 1
package AHA; public class CLASS2 { public CLASS2() { System.out.println("Welcome Srajan"); } }
11th Jul 2018, 7:11 PM
SRAJAN GUPTA
SRAJAN GUPTA - avatar
+ 1
above two are the codes of two .java files
11th Jul 2018, 7:13 PM
SRAJAN GUPTA
SRAJAN GUPTA - avatar