-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyClassDemo.java
57 lines (52 loc) · 1.3 KB
/
MyClassDemo.java
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
public class MyClassDemo
{
public static void main(String[] args)
{
for (int i = 0;i <= 10;i = i + 2) {
System.out.print(i + ":" + i+3 + "-");
} // end of for
System.out.println();
System.out.println("The End");
/* int a = 6, b = a/4, c = a % 4;
double d = a/4.0;
System.out.println("a="+a+b+"="+b+"c="+c+"d="+d);
a = b;
b = c;
d = Math.pow(b,c);
System.out.println("a="+a+"b="+b+"c="+c+"d="+d); */
//MyClass myObject1 = new MyClass(5);
//MyClass myObject2 = new MyClass(7);
//myObject1.printX();
//myObject1.incrementCount();
//MyClass.incrementCount();
//myObject1.printCount();
//myObject2.printCount();
//myObject2.printX();
//myObject1.setX(14);
//myObject1.incrementCount();
//myObject1.printX();
//myObject1.printCount();
//myObject2.printCount();
}
}
class MyClass
{
private static int count = 0;
private int x;
public MyClass(int i)
{
x = i;
}
public void incrementCount()
{
count++;
}
public void printX()
{
System.out.println("Value of x : " + x);
}
public static void printCount()
{
System.out.println("Value of count : " + count);
}
}