Skip to content

Commit 1d850b7

Browse files
authored
Create alphanum.java
1 parent 10fed81 commit 1d850b7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

String/alphanum.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package STr;
2+
3+
import java.util.Scanner;
4+
5+
public class thir {
6+
7+
public static void main(String[] args) {
8+
//alphanumeric
9+
10+
Scanner sc = new Scanner(System.in);
11+
//how*was23your&today
12+
System.out.println("Enter alphanumeric String : ");
13+
14+
String str = sc.nextLine();
15+
16+
StringBuffer alpha = new StringBuffer(),
17+
num = new StringBuffer(),
18+
special = new StringBuffer();
19+
20+
for(int i=0; i<str.length(); i++)
21+
{
22+
if(Character.isDigit(str.charAt(i)))
23+
{
24+
num.append(str.charAt(i));
25+
}else if(Character.isAlphabetic(str.charAt(i)))
26+
{
27+
alpha.append(str.charAt(i));
28+
}else {
29+
special.append(str.charAt(i));
30+
}
31+
}
32+
33+
System.out.println(num);
34+
System.out.println(alpha);
35+
System.out.println(special);
36+
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)