java own package use-plz somebody help

Discussion in 'Java' started by Boaz, Sep 23, 2012.

  1. Boaz

    Boaz New Member

    Sep 3, 2012
    Likes Received:
    Trophy Points:
    i have heard the uses of packages.
    we can create our own package.and then can import and access it frm another package.
    i have tried it.but ends up with failure.

    now, my first package's source D:\javacodings\codings\try
    try is the nam eof my package,and it contains. file ''
    and the content in the file
    Package try;
    public class sample
    public void add()
    System.out.println("package works");
    my send package D:\javacodings\codings\usingtry
    it contains ""
    and its content
    Package usingtry;
    import try.*;
    class sam
    public static void main(String a[])
    sample s=new sample();
    i have tried to use the sample class in try package,,
    when i tr y to compile the file in my try package,,i.e

    i get the following error

    D:\javacodings\codings\try>javac 'class' or 'interface' expected
    Package try;
    1 error

    plzzzz tell what mistake i have done,,
    and correct it,,
    thank yu
    Last edited by a moderator: Sep 24, 2012

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice