Hi ,
Plz read the following and
Clear my doubts.
//Test1.java
//place this program in ur local disk say
c:\temp
package mypackage;
public class Test1
{ public Test1() { }
public static void main(String []args) { System.out.println("Now in Test1 program"); } public void print() { System.out.println("Now in Test1------->print()"); } } compile it by javac -d . Test1.java
//Save this program in ur local directory say
c:\temp
//Test2.java
import mypackage.*;
public class Test2
{ public static void main(String
[]args)
{ Test1 t1 = new Test1(); t1.print(); } }
If i try to compile it then i am getting
error.
a) In Test2.java if i replace the import statement
with the following one
import
mypackage.Test1;
then Test2.java is
compiled
b) If i placed any package statement like
package xxxx;
in Test2.java then it is
compiled.
Why it is occurring like this.
Thanks and Regards,
Sreedhar |
- Re: Doubt regarding Java Code Sreedhar M
- Re: Doubt regarding Java Code viju
- Re: Doubt regarding Java Code Sreedhar M
- Re: Doubt regarding Java Code Ken Barron
- Re: Doubt regarding Java Code Raghupathy, Gurumoorthy