-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathoverloading.java
More file actions
75 lines (47 loc) · 1.02 KB
/
overloading.java
File metadata and controls
75 lines (47 loc) · 1.02 KB
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
61
62
63
64
65
66
67
68
69
70
71
import java.io.*;
class overloading
{
public static void display(String str,char chr)
{
int l,i;char b = ' ';
l=str.length();
str=str+" ";
if(chr=='e')
for(i=0;i<l;i++)
{
if(i%2==0)
{
System.out.println(str.charAt(i));
}
else
{
System.out.println(str.charAt(i+1));
}
break;
}
}
public static void Display(String str,int p)
{
if(p==1)
System.out.println(str.indexOf('a'));
else
System.out.println(str.lastIndexOf('a'));
}
public static void main(String args[])throws IOException
{
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader y = new BufferedReader(in);
String str1;char chr1;
System.out.println("enter a string ");
str1= y.readLine();
System.out.println("enter a char");
chr1= (char)(y.read());
String str2;int p1;
System.out.println("enter a string ");
str2 = y.readLine();
System.out.println("enter an int");
p1 = Integer.parseInt(y.readLine());
display(str1,chr1);
Display(str2, p1);
}
}