First of all

segment(point a,point b)   is the constructor…



you can use it to initialize values & call other constructors… but I
don’t believe its good practice (maybe not even possible) to use it
any other way




On Feb 17, 8:37 am, prasad jedhe <[email protected]> wrote:
> -->what do i write in class segment to print the contents of pi n p2 objects
> which i have created in main...i mean i want to print "segment is:
> (1,3)(3,3)" in segment class...am creating a small project "rectangle" using
> shared memory approach.i.e one segment with two points.. i need your help..
> thnx... :)
>
> package javaapplication1;
> public class Main
> {
>     public static void main(String[] args)
>     {
>       point p1=new point(1,3);
>       point p2=new point(3,3);
>       p1.print();
>       p2.print();
>       segment s1=new segment(p1,p2);
>     }
>
> }
>
> class point
> {
>     private int x;
>     private int y;
>
>         point(int a, int b)
>             {
>                 x=a;
>                 y=b;
>             }
>         void print()
>             {
>                 System.out.println("Point is:("+x+","+y+")");
>             }
>
> }
>
> class segment
> {
>     private point p1;
>     private point p2;
>
>         segment(point a,point b)
>             {
>                 System.out.println("segment is:");
>             }
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to