GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaTutorial/src/21_ClassObjects.java at master · KumiM01/JavaTutorial Expand file tree/ Copy path21_ClassObjects.javaMore file actions 60 lines (43 loc) · 924 Bytes / Copy path21_ClassObjects.javaFile metadata and controls60 lines (43 loc) · 924 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 /** * * Class, Objects, Instance and Field Variable * */ public class Main { public static void main(String[] args) { Rectangle r1 = new Rectangle(); r1.setLength(10); r1.setBreadth(20); Rectangle r2 = r1; r2.setLength(50); r2.setBreadth(100); Rectangle r3 = new Rectangle(); Rectangle r4 = new Rectangle(); Rectangle r5 = new Rectangle(); System.out.println(r1.getBreadth()); System.out.println(r1.getLength()); } } public class Rectangle { int length; // or it can be float int breadth; public float getArea() { float area = length * breadth; return area; } public float findPerimeter() { int p = 2 * ( length + breadth ); return p; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public int getBreadth() { return breadth; } public void setBreadth(int breadth) { this.breadth = breadth; } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |