-
what is error with this class ?
Hello ..
i wrote this class
Code:
public class BBS
{
public String name;
public String creator;
public String website;
public BBS(String name, String creator, String website)
{
this.name = name;
this.creator = creator;
this.website = website;
}
public int GetInfo()
{
System.out.println("Bulletin Board System Name is " + this.name);
System.out.println("Bulletin Board System programme is " + this.creator);
System.out.println("More infromation about " + this.name + " at " + this.website);
System.out.println("=========================================================");
return 0;
}
}
and i saved this class in file "BS.java" and i make object in "example.java" and use it :
Code:
package BBS;
public class example
{
public static void main(String[] args)
{
BBS MySmartBB = new BBS("MySmartBB","MaaSTaaR","http://www.mysmartbb.com");
BBS vBulletin = new BBS("vBulletin","Jelsoft Team","http://www.vbulletin.com");
BBS phpBB = new BBS("phpBB","phpBB Team","http://www.phpbb.com");
MySmartBB.GetInfo();
vBulletin.GetInfo();
phpBB.GetInfo();
}
}
and when i do compile , it's show for me these errors
example.java:7: cannot resolve symbol
symbol : class BBS
location: class BB.example
BBS MySmartBB = new BBS();
^
where is the problem in code?
-
your BS.java should have the same name as its class - so it should be BBS.java.
You need to include the BBS.java file in the BBS package - if you are insisting on making this a package. The compiler cannot find code for a BBS class in the package.
-
Hello ...
thank you very much nspils for your help 
your BS.java should have the same name as its class - so it should be BBS.java.
true , filename is BBS.java , sorry for this error
You need to include the BBS.java file in the BBS package - if you are insisting on making this a package. The compiler cannot find code for a BBS class in the package.
i am beginner in Java so i don't understand you well in this point , how i can include BBS class in my example.java file ?
-
Take out your reference to a BBS package.
You don't need to make explicit mention or "include" the BBS file. Your reference to an object of the BBS class will prompt the compiler to look for a BBS class file. If the class file is in the classpath, the compiler will use it to build your BBS object. If the java file is in the classpath, the compiler will compile the BBS.java file in addition to your example.java file.
So - the lesson is, to have the BBS.java and/or BBS.class file in the same directory as you have your example.java file when you call the compiler.
Similar Threads
-
By none_none in forum Java
Replies: 17
Last Post: 04-28-2005, 03:00 PM
-
Replies: 5
Last Post: 10-17-2002, 01:58 PM
-
By Shailesh C.Rathod in forum .NET
Replies: 2
Last Post: 03-13-2002, 08:53 PM
-
By Patrick Ireland in forum .NET
Replies: 5
Last Post: 05-10-2001, 06:19 PM
-
Replies: 1
Last Post: 11-09-2000, 06:38 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|