-
Notifications
You must be signed in to change notification settings - Fork 25
/
Test1.java
48 lines (45 loc) · 885 Bytes
/
Test1.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
package Threads;
class Reverse
{
static int num;
int find(int num)
{
int reversed = 0;
while(num != 0) {
int digit = num % 10;
reversed = reversed * 10 + digit;
num /= 10;
}
return reversed;
}
}
class ReverseR extends Reverse
{
int find(int num)
{
if (num < 10)
{
System.out.println(num);
return num;
}
else
{
System.out.print(num % 10);
find(num/10);
}
return num;
}
}
public class Test1
{
public static void main(String args[])
{
ReverseR obj = new ReverseR();
obj.find(5741);
Reverse obj2 = new ReverseR();
obj2.find(5741);
Reverse obj3 = new Reverse();
int z = obj3.find(5741);
System.out.println(z);
}
}