Results 1 to 3 of 3
  1. #1
    tyang is offline Member
    Join Date
    Jan 2010
    Posts
    44
    Rep Power
    0

    Default A difficult question

    Can anyone help me with this? THANK YOU VERY MUCH!

    If the java file name is ABC.java.
    Why are some classes defined before the public class ABC?
    e.g.
    class sparse_binary_vector
    {
    Vector id = new Vector();
    }

    class sparse_vector
    {
    Vector id = new Vector();
    Vector val = new Vector();
    }

    public class ABC
    {
    ...
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default

    You can define more than one class in a single source file but only one of them can be public, the other classes have to have package scope. More than one class per source file suggests a tight coupling of the non-public classes with the single public class. It can be abused though.

    kind regards,

    Jos

  3. #3
    tyang is offline Member
    Join Date
    Jan 2010
    Posts
    44
    Rep Power
    0

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. Difficult compilation
    By pochis40 in forum Java Applets
    Replies: 10
    Last Post: 12-21-2009, 12:35 PM
  3. ur help on my question
    By jameela in forum New To Java
    Replies: 4
    Last Post: 10-13-2008, 12:38 PM
  4. Java's web world is really difficult..
    By jurka in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-02-2008, 05:33 PM
  5. question on jsp
    By munigantipraveen in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-30-2008, 02:47 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
  •