a class accessing a class in a different package

Hi,

I have a class:

package PackYes;
public class A
{
public static int a=10;
}

like this and another class in a different package like this:

package MyPack2;
import PackYes.A;

public class B extends A
{
public static void main(String []args)
{
System.out.println(a);
}
}

I dont quite understand the way to set a directory structure for these two packages.Help me....








Comments

  • : Hi,
    :
    : I have a class:
    :
    : package PackYes;
    : public class A
    : {
    : public static int a=10;
    : }
    :
    : like this and another class in a different package like this:
    :
    : package MyPack2;
    : import PackYes.A;
    :
    : public class B extends A
    : {
    : public static void main(String []args)
    : {
    : System.out.println(a);
    : }
    : }
    :
    : I dont quite understand the way to set a directory structure for
    : these two packages.Help me....
    :
    :
    :
    The directory structure is like this:
    [code]
    srcB.java
    srcpackyesa.java
    [/code]
    I would suggest that you use an IDE (such as Eclipse or JCreator) for your code editing, because it will automatically handle things like this for you.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion