constructor demo
constructordemo
/** * */ /** * @author arun * */ class triangle { int base; int height; void area() { System.out.println("area of trianglle is"); System.out.println(base*height/2); } } public class classdemo{ public static void main(String[] args) { triangle t1 = new triangle(); triangle t2 = new triangle(); t1.base = 10; t1.height = 20; t2.base = 40; t2.height = 30; t1.area(); t2.area(); } } /* output * area of triangle is 100 area of triangle is 600 */
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/