Java Program Simple Class Example

This java code shows you a simple class example.
class Time
{
                int h,m,s;
}
class Time_Demo1
{
                public static void main(String args[])
                {
                Time t1=new Time();
                Time t2=new Time();
                t1.h=10;
                t1.m=2;
                t1.s=30;
                t2.h=3;
                t2.m=6;
                t2.s=34;
                System.out.println(t1.h +”:”+t1.m+”:”+t1.s);
                System.out.println(t2.h +”:”+t2.m+”:”+t2.s);
                }
}

Add Comment