We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cea2733 commit 4739ecdCopy full SHA for 4739ecd
module2/ReferceVariable.java
@@ -0,0 +1,30 @@
1
+// Program to create a reference variable
2
+import java.util.Scanner;
3
+class Area
4
+{
5
+ double length;
6
+ double weadth;
7
+
8
+ public void inputValues()
9
+ {
10
+ Scanner reader = new Scanner(System.in);
11
+ System.out.print("\nEnter the length: ");
12
+ length = reader.nextDouble();
13
+ System.out.print("\nEnter the weadth: ");
14
+ weadth = reader.nextDouble();
15
+ }
16
+ public double showArea()
17
18
+ return length*weadth;
19
20
+}
21
+public class ReferceVariable
22
23
+ public static void main(String args[])
24
25
+ Area obj1 = new Area();
26
+ Area obj2 = obj1; // Refernce Variable
27
+ obj1.inputValues();
28
+ System.out.print("\nThe area is " + obj2.showArea());
29
30
0 commit comments