Home can i define more than one public class in a java package
Reply: 0

can i define more than one public class in a java package

user688
1#
user688 Published in May 25, 2018, 8:57 am

i want to create a java package containing some classes .But non public classes cannot be accessed from outside a package so i write this code a saved it as Box.java

package mypack;
public class Box
{
int length,breadth,height;
public Box(int l,int b,int h)
    {
    length=l;
    breadth=b;
    height=h;
    }
public  int vol()
    {
    return length*breadth*height;
    }
} 

public class circle
{
 int r;
 public circle(int rr)
    {
    r=rr;
    }
 public float area()
    {
    return (3.14f*r*r);
    }
 }  

is it possible to create a package like this . if possible what file name should i give it 'Box.java' or 'circle.java'

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.434612 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO