what is error with this class ?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: what is error with this class ?

  1. #1
    Join Date
    Dec 2005
    Posts
    2

    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?

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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.

  3. #3
    Join Date
    Dec 2005
    Posts
    2
    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 ?

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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

  1. Help with class/applet
    By none_none in forum Java
    Replies: 17
    Last Post: 04-28-2005, 04:00 PM
  2. Replies: 5
    Last Post: 10-17-2002, 02:58 PM
  3. Assembly class
    By Shailesh C.Rathod in forum .NET
    Replies: 2
    Last Post: 03-13-2002, 08:53 PM
  4. How To Do It - Shared Class Variables Part III
    By Patrick Ireland in forum .NET
    Replies: 5
    Last Post: 05-10-2001, 07:19 PM
  5. Calling base class methods
    By GR in forum Java
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center