TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
SIVA
NA
742
706.5k
How to import packages in java
Jan 2 2012 3:33 PM
Hi All,
I have one doubt regarding Java.
I have 2 packages in java. In that i have imported one package into another
as follows.
package package1;
public class Base1{
public void Method1(){
System.out.println("Method1");
}
}
package package2;
import package1;
public class Base2{
public void Method2(){
System.out.println("Method2");
Base1 b1=new Base1();
b1.Method1();
}
}
import package2;
public class clsMain{
public static void main(String[] args){
Base2 b2=new Base2();
b2.Method2();
}
}
Can any body tell me this
its showing some errors as follows
while compiling the second file Base2 the following error is coming
Base2.java:2: '.' expect
import Package1;
and While compiling the clsMain file its showing following errors
clsMain.java:1: package package2 does not exist
import package.*;
^
.\Base21.java:2: '.' expected
import Package1;
^
Use.java:9: cannot access Base2
bad class file: .\Base2.java
file does not contain class Base2
Please remove or make sure it appears in
th.
Base2 m = new Base2();
If anything wrong is there in this can you give code for this scenario please
Reply
Answers (
1
)
Would Mahatma Gandhi have made a good software engineer?
How to Create Video